We consider the Poisson sigma model associated to a Poisson manifold. The perturbative quantization of this model yields the Kontsevich star product formula. We study here the classical model in the Hamiltonian formalism. The phase space is the space of leaves of a Hamiltonian foliation and has a natural groupoid structure. If it is a manifold then it is a symplectic groupoid for the given Poisson manifold. We study various families of examples. In particular, a global symplectic groupoid for a general class of two-dimensional Poisson domains is constructed.