Pope Francis has criticised drug legalisation plans in Latin America during the inauguration of a clinic for drug addicts in Rio de Janeiro.
The roots of drug abuse should be tackled, he said on the third day of his visit to Brazil.
Uruguay is close to allowing the legal sale of marijuana, with other countries pondering similar liberalisation.
Earlier, the Argentine-born pontiff celebrated the first Mass of his trip, at the Shrine of Our Lady of Aparecida.
He warned tens of thousands of faithful against the "passing idols" of money, power and pleasure.
After the visit to Aparecida, in the Brazilian state of Sao Paulo, the pope flew back to Rio de Janeiro.
At the inauguration of a drug rehabilitation clinic at the Sao Francisco hospital, he hugged former addicts and heard their stories.
'Dealers of death'
"It is necessary to tackle the problems which are at the root of drug abuse, promoting more justice, educating the youth with the values that live in society, standing by those who face hardship and giving them hope for the future," he said.
Pope Francis also warned against plans to legalise drugs in Latin America and condemned drug-traffickers.
"How many dealers of death there are that follow the logic of power and money at any cost! The scourge of drug-trafficking, that favours violence and sows the seeds of suffering and death, requires of society as a whole an act of courage," he said.
Leaders in Colombia, Bolivia, Ecuador and others have spoken for softer stances on drugs policy.
In Uruguay, a project decriminalising marijuana sale is set to be voted in Congress next week.
President Jose Mujica says its main goal is combating drug trafficking.
On Monday the Pope faced chaotic scenes as he arrived in Rio de Janeiro.
He is in Brazil to attend the Roman Catholic World Youth Day festival. It is his first trip abroad since becoming head of the Catholic Church in March.
The highlight of the five-day festival will be a prayer service on Rio's iconic Copacabana Beach on Thursday.
The pontiff's visit is taking place under tight security, after weeks of anti-government protests.
He travelled to the shrine in Aparecida by plane and helicopter.
Thousands of pilgrims arrived in the rural town ahead of Wednesday's Mass, which took place at the basilica holding the shrine.
"It is true that nowadays, to some extent, everyone, including our young people, feels attracted by the many idols which take the place of God and appear to offer hope - money, success, power, pleasure," the pontiff said during the service.
Twelve thousand people were estimated to have been inside the basilica, the BBC's Julia Carneiro reports.
Up to 200,000 more were outside watching the service on big screens, our correspondent adds.
After his Mass, the Pope appeared on a balcony to greet the crowds.
A homemade explosive device was discovered at the shrine on Sunday, but authorities said it was "of low power" and not near the area where the Pope and pilgrims will visit.
The Vatican later insisted that the discovery was no cause for concern.
On Tuesday, around 400,000 Roman Catholics joined a ceremony on Copacabana Beach to mark the opening of World Youth Day.
There was transport chaos shortly before the event when the Rio metro system was brought to a standstill for two hours by a power cut.
Crowds of people hoping to attend the Mass were left stranded, while others crammed onto buses and taxis heading to the beach.
Travel chaos also ensued on Monday when the pontiff's car became stuck in one of Rio's infamous traffic jams, after his driver reportedly took the wrong turn and missed lanes that had been cleared by the security services.
Correspondents said Brazil was reviewing security around the pontiff following the incident.
The Pope, who is from neighbouring Argentina, was officially welcomed at the state governor's palace by Brazil's President Dilma Rousseff on Monday.
However police later fired tear gas to disperse people who were demonstrating outside. They were protesting against the government and also against the cost of the papal visit.
More than a million young Catholics are expected to gather in Rio for World Youth Day, which takes place every two years and is a celebration of the Catholic faith.
Some 30,000 army and police are on duty throughout his visit.
Guanabara Palace (22 July)
When Pope Francis arrives in Rio, he will attend a welcome ceremony in Guanabara Palace. Guests will include Brazillian President Dilma Rousseff.
Sumare Centre (22 July)
The catholic education institution will be the Pope's residence during his stay in Rio.
Our Lady of Aparecida Basilica (24 July)
The Pope travels to the National Shrine of Our Lady of Aparecida in the city of Aparecida do Norte, the largest Marian pilgrimage centre in the world. He will celebrate a mass there and return to Rio on the same day.
St. Francis of Assisi Hospital (24 July)
As soon as he returns from Aparecida do Norte, the pontiff will inaugurate a special ward for the treatment of drug addicts, built with donations from the Vatican.
City Palace (25 July)
The Pope will be handed the keys to the city from mayor Eduardo Paes. Later, he will bless the Olympic flags for Rio 2016.
Varginha slum, Manguinhos (25 July)
Pope Francis visits the community living in the Varginha slum and will make a speech in a local football field.
Copacabana beach (25-26 July)
The Pope will greet the participants of the Church's World Youth Day on 25 July. The next day, they will join him in a Way of the Cross procession at the beach.
Quinta da Boa Vista (26 July)
The Pope receives the confession of five youngsters in a house that was used by Brazil's royal family members.
St. Joachim Archiepiscopal Palace (26 July)
The pontiff will meet young prisoners. After that, he will deliver the Angelus prayer and blessing from the palace balcony and meet youngsters from the organising committee of World Youth Day for lunch.
Rio de Janeiro Municipal Theatre (27 July)
Pope Francis meets politicians and local dignitaries.
Campus Fidei, Guaratiba (27-28 July)
The Pope will hold a vigil with the participants of World Youth Day on Saturday evening. On Sunday morning, Pope Francis will celebrate the final mass of the WYD 2013 and deliver the Angelus prayer and blessing once again.
Riocentro (28 July)
On his way to the airport, the pontiff stops in Riocentro, the largest convention centre in Latin America, to meet the WYD volunteers.
Galeao International Airport (28 July)
In his last engagement in Brazil, the pope will make a speech in a farewell ceremony at the airport.