A method for Monte Carlo studies of phase equilibrium in confined systems is presented using an example of vapor-liquid equilibrium (capillary condensation and evaporation) in cylindrical pores. The method, named the gauge cell method, allows one to construct the full phase diagram of a confined fluid in the form of a van der Waals loop, which includes stable, metastable, and unstable equilibri...