This is by far the most convenient and cheapest way to visit St. Peter’s Basilica. Take the Line A and get down at the Ottavanio Station which is just near the Vatican Walls. A 5 minute walk will take you to St. Peter’s Square and the Vatican Museums.
The bus numbers 40 and 64 leave from Termini (Rome) and drop you near the Vatican (Piazza Pia). It is a short walk of 5 minutes to St. Peter’s Square.
The Vatican also has a train station, St Pietro, and serves commuter style trains travelling between Rome and Termini Stations. However, it is a 10 minute walk to St Peter's Square from the station.