In this paper, we discuss optimality conditions for optimization problems involving random state constraints, which are modeled in probabilistic or almost sure form. Although the latter can be understood as the limiting case of the former, the derivation of optimality conditions requires substantially different approaches. We apply them to a linear elliptic partial differential equation with random inputs. In the probabilistic case, we rely on the spherical-radial decomposition of Gaussian random vectors in order to formulate fully explicit optimality conditions involving a spherical integral. In the almost sure case, we derive optimality conditions and compare them with a model based on robust constraints with respect to the (compact) support of the given distribution. Funding: The authors thank the Deutsche Forschungsgemeinschaft [Projects B02 and B04 in the “Sonderforschungsbereich/Transregio 154 Mathematical Modelling, Simulation and Optimization Using the Example of Gas Networks”] for support. C. Geiersbach acknowledges support from the Deutsche Forschungsgemeinschaft [Germany’s Excellence Strategy–the Berlin Mathematics Research Center MATH+ Grant EXC-2046/1, Project 390685689]. R. Henrion acknowledges support from the Fondation Mathématique Jacques Hadamard [Program Gaspard Monge in Optimization and Operations Research, including support to this program by Electricité de France].