We study here an optimal control problem for a semilinear elliptic equation with an exponential nonlinearity, such that we cannotexpect to have a solution of the state equation for any given control. We then have to speak of pairs (control, state). After havingdefined a suitable functional class in which we look for solutions, we prove existence of an optimal pair for a large class of costfunctions using a non standard compactness argument. Then, we derive a first order optimality system assuming the optimal pair isslightly more regular.