Trains run along four different routes: between Cusco and Machu Picchu, between Cusco and Lake Titicaca, between Huancayo and Lima, and between Huancayo and Huancavelica. In addition there's a line between Puno and Arequipa that's operated for groups only. Tickets can be purchased at train stations, through travel agencies, or on the Internet. During holidays or high season it's best to get your tickets in advance.
Three companies offer train service to Machu Picchu. PeruRail, which has run the route since 1999, is operated by Orient-Express, the same company that runs one of the most luxurious and famous trains in the world, the Venice Simplon Orient Express between London and Venice. It operates service to Machu Picchu from Cusco (technically from the nearby town of Poroy, about 20 minutes outside the city) and the Sacred Valley towns of Ollantaytambo and Urubamba. Inca Rail and Andean Railways, which began service in 2010 and 2011, respectively, run service between Urubamba, Ollantaytambo, and Machu Picchu. Foreigners are prohibited from riding the very inexpensive local trains that travel the route. The Machu Picchu station is not at the ruins themselves, but in the nearby town of Aguas Calientes.
Three or four PeruRail trains a week, depending on season, take passengers on the 10-hour trip between Cusco and Lake Titicaca. The plush Andean Explorer is $210 USD one-way.
Note that there are two different train stations in Cusco. Estacin Poroy serves the Machu Picchu route, and Estacin Wanchaq serves the Lake Titicaca route.
Reserve and purchase your ticket as far ahead as possible, especially during holidays or high season. Reservations can be made directly with PeruRail through its website, or through a travel agency or tour operator.
Inca Rail (Portal de Panes 105, Plaza de Armas, Cusco. 084/581–860 in Cusco; 01/613–5288 in Lima. www.incarail.com.)
PeruRail (Portal de Carnes 104, Plaza de Armas, Cusco. 084/581–414. www.perurail.com.)
Estación Wanchaq (Cusco–Lake Titicaca route) (Pachacutec 503, Cusco. 084/581–400.)
Estación Poroy (Cusco - Machu Picchu Route) (Poroy, Cusco. 084/581-414.)