Abstract : This paper deals with state-constrained optimal control problems governed by semilinear elliptic equations or variational inequalities. By using Ekeland's principle, we derive a minimum principle of Pontryagin's type under some stability conditions of the optimal cost with respect to the state constraints.