We consider surfaces immersed in three-dimensional pseudohermitian manifolds. We define the notion of (p-)mean curvature and of the associated (p-)minimal surfaces, extending some concepts previously given for the (flat) Heisenberg group. We interpret the p-mean curvature not only as the tangential sublaplacian of a defining function, but also as the curvature of a characteristic curve, and as a quantity in terms of calibration geometry. As a differential equation, the p-minimal surface equation is degenerate (hyperbolic and elliptic). To analyze the singular set (i.e., the set where the (p-)area integrand vanishes), we formulate some extension theorems, which describe how the characteristic curves meet the singular set. This allows us to classify the entire solutions to this equation and to solve a Bernstein-type problem (for graphs over the xy-plane) in the Heisenberg group H1. In H1, identified with the Euclidean space R3, the p-minimal surfaces are classical ruled surfaces with the rulings generated by Legendrian lines. We also prove a uniqueness theorem for the Dirichlet problem under a condition on the size of the singular set in two dimensions, and generalize to higher dimensions without any size control condition. We also show that there are no closed, connected, C2 smoothly immersed constant p-mean curvature or p-minimal surfaces of genus greater than one in the standard S3. This fact continues to hold when S3 is replaced by a general pseudohermitian 3-manifold. Mathematics Subject Classification (2000): 35L80 (primary); 35J70, 32V20, 53A10, 49Q10 (secondary).