US President Barack Obama has praised Brazil as a model of democracy, during a visit to the country.
Mr Obama - on a five-day Latin American tour - said Brazil's flourishing economy and growing democracy were a model for countries in the Middle East.
Earlier, the US president visited the City of God, one of Rio de Janeiro's shantytowns, where he met local people.
The visit to Rio follow talks in Brasilia with Brazilian President Dilma Rousseff that focused on trade.
Mr Obama, whose visit is being partly overshadowed by events in Libya, is to travel on to Chile and El Salvador.
In his speech, Mr Obama referred to Libya, saying "a new generation" was demanding the right to determine its own future.
"From the beginning, we have made clear that the change they seek must be driven by their own people. But as two nations who have struggled over many generations to perfect our own democracies, the United States and Brazil know that the future of the Arab World will be determined by its people".
Mr Obama arrived in Rio de Janeiro after a day of talks in the capital, Brasilia, with Ms Rousseff and business leaders.
In a joint news conference, he and Ms Rousseff emphasised Brazil's growing economic power and the opportunities to work more closely together.
However, there was no direct US endorsement of Brazil's bid to become a permanent member of the UN Security Council, a move that left Ms Rousseff clearly frustrated at the lack of stronger support.
Ahead of Mr Obama's arrival in Rio, authorities stepped up security and closed a number of streets in preparation.
Mr Obama and his wife, Michelle, visited the City of God (Cidade de Deus) favela, one of several hundred shantytowns that dot Rio's hills.
The shantytown is one of several "pacified" under a programme to reduce violence in the city, which is set to be in the international limelight with the World Cup in 2014 and the Olympic Games two years later.
The programme involves the deployment of a permanent police presence, known as the Police Pacification Units (UPP), that aim to drive out the drug traffickers who control the slums.
People here told the BBC that they hoped President Obama would see that their favela was a far cry from the crime-ridden slum made famous by the movie City of God.
"We are not animals here but lovely people who welcome everybody," said nurse Tamara Rubia.
During his tour, Mr Obama watched a performance by children of capoeira, which brings together martial arts, dance and music. He also had a quick kickabout with local youngsters playing football.
Mr Obama delivered his speech at the Rio de Janeiro Municipal Theatre. His speech was originally planned to be an outdoor event but was moved inside due to a "number of concerns", US officials said.
Mr Obama will end his Rio visit with a tour of the famed Christ the Redeemer hilltop statue.
The visit was rescheduled from morning to evening to allow Mr Obama time to be briefed on the situation in Libya, where US, UK and French aircraft have been in action against the forces of Libyan leader Col Muammar Gaddafi.
Brazil is the eighth largest importer of US goods, and the amount it buys from the US is growing rapidly, White House aides say.
In Chile, Mr Obama will make a speech laying out goals on energy co-operation, security, economic growth and development, and democracy and human rights, White House aides said.
El Salvador is home to one of America's largest Hispanic populations. But its murder rate has been climbing, as have cocaine seizures in the country and what is perceived by some as growing insecurity is concerning US officials.
Mr Obama will have talks with left-wing El Salvadoran President Mauricio Funes. BBC News