Pope Leo XIV drew vast crowds to Argentina's holiest shrine in Luján on Wednesday, the final day of his visit before he departs for Peru, where he spent nearly two decades as a missionary. 

Authorities said over three million people packed the streets around the Basilica of Luján, with some climbing fences, barriers, trees and lampposts for a glimpse of the pontiff. 

Crowds chanted "Thank you Leo!" to the 71-year-old pope, who is on a 12-day tour of Uruguay, Argentina and Peru less than a month after undergoing surgery for lung cancer. 

The stop at Luján was the emotional centerpiece of Leo's first visit to Argentina, where his predecessor Francis never managed to return home as pope.

Former Italy Red Brigades member escapes in Argentina ahead of extradition

"Thank you, Argentina, for welcoming me with open arms," he said as he bid farewell to the thronging crowd, which was the largest he drew during his visit to the country. 

"It was a unique, unforgettable experience," said 36-year-old Daiana Rivero.

"The Pope's visit leaves a very powerful emotion and I feel this is going to be a turning point for our country," she said.

Pope Leo visits prisoners, urges them to ‘restart their lives’

Throughout his stay in Argentina, Leo has pointedly demanded a more inclusive economy and better protections for the vulnerable, comments widely interpreted as criticism of aid-slashing President Javier Milei. 

On Wednesday, the pontiff insisted "there is room for everyone, especially the neediest: the poor and hungry, migrants, the sick and prisoners." 

He wore a white-and-sky-blue robe associated with the Virgin of Luján, echoing the colours of the Argentine flag. 

Iran lists Argentina’s Navy, Air Force as terrorist organisations

The country's social and political tensions were on display in the crowd, with one group unfurling a banner reading "Land, housing and work for the people." 

Pilgrim Estela Adorno, 76, said the Pope's message had resonated in a country marked by political and economic divisions. 

"Everything that helps society is welcome. People were deeply moved, I was deeply moved. With everything that is happening in the country, it will always be welcome," she added.

Volunteers handed out water in the crowd as pilgrims streamed into Luáan under the spring sun. 

Inside the basilica, choir members described performing at the mass as a once-in-a-lifetime occasion. 

"It is a unique opportunity, full of emotion. From the moment we were told we would participate, through preparing the repertoire and these final days of rehearsals, there has been so much shared excitement," said choir member Nora Jauregui, a 61-year-old retired music teacher. 

Earlier Wednesday, Leo visited Buenos Aires' Devoto Prison, where he urged inmates to use their time behind bars as an opportunity to rebuild their lives. 

"Human beings often flourish through limits rather than despite them," the Pope told around 75 inmates and family members gathered in the prison gymnasium. 

He acknowledged the hardship of prison life, saying he could imagine their sleepless nights and thoughts of loved ones or those they may have harmed. 

The US-born Pope had refused to reschedule the trip to South America despite having the lower part of his right lung removed to extract a cancerous tumor. 

In Peru, he will visit the Amazon, the Andean city of Cuzco at 3,400 metres (11,000 feet) above sea level, and the northern city of Chiclayo, where he spent a decade as bishop.

Formal down, informal up – employment in Argentina's since Milei’s labour reform