Damaged buildings, including hotels, were flooded by the Vilcanota River in Cuzco, Peru, on Thursday. Hundreds of tourists waited to be airlifted out after flooding and mudslides stranded them near the Incan citadel of Machu Picchu. ((Mariana Bazo/Associated Press))

Helicopters ferried out the last tourists stranded near Machu Picchu on Friday, leaving the Peruvian government to contemplate a prolonged shutdown of its top tourist site.

A total of 3,900 tourists and local people were flown out of the tiny mountain village of Machu Picchu Pueblo this week after mudslides and torrential rains on Sunday destroyed sections of the railway that is the only form of transit in and out of the village below the Machu Picchu citadel.

The remaining 1,277 tourists were evacuated Friday as authorities raced to complete the job against darkening skies, police Col. Santiago Vizcarra told The Associated Press.

An estimated 700 Argentines, 400 Americans, 300 Chileans and 200 Brazilians were among the tourists visiting the area when the mudslides began.

Helicopters began airlifting people out on Tuesday, the same day authorities barred any more hikers from walking the Inca Trail after mudslides killed two people on the trail. At least three other people have been reported killed in mudslide related deaths.

People who had started the hike already remained on the trail and were expected to arrive at Machu Picchu by Friday. The trail takes about four days to traverse.

Thousands affected by flooding

Five days of torrential rains in the region centred on the town of Cuzco have destroyed bridges, some 250 houses and hundreds of hectares of crops.

Peru's government announced a 60-day state of emergency on Tuesday in the region and has sent 20 tonnes of relief aid to the affected zones, according to local news agencies.

Alberto Bisbal, a director at the national civil defence authority, told Lima-based Canal N television about 36,000 people have been affected and as many as 2,000 homes destroyed.

Authorities have also said the Inca Trail and Machu Picchu will likely remain closed for weeks until the government can repair highway and railroad tracks washed out by mudslides and the raging Urubamba River.

Many people in the region depend on tourists travelling to Machu Picchu for their livelihood, adding another strain to a population already living in poverty.

Hugo Gonzales, Cuzco's governor, has estimated the cost of damages at around $280 million US.

With files from The Associated Press