President Obama in a speech Sunday cast Brazil as an example of the kind of flourishing democracy he hopes can emerge in the Arab world.

With his tour of Latin America overshadowed by allied bombardments against Libyan leader Moammar Gaddafi’s forces, Obama sought to link the events in North Africa and the Middle East to Brazil, his first stop in a five-day trip to promote American exports. The president’s message extolling the virtues of Brazilian democracy was delivered from an ornate theater that was the scene of protests against a dictatorship that ended in 1985.

“You fought against two decades of dictatorships for the same right to be heard – the right to be free from fear and free from want,” Obama said before a crowd of 2,000 people. “Brazil today is a flourishing democracy, a place where people are free to speak their mind and choose their leaders.”

In his speech, which was broadcast on national television, Obama mentioned Libya just once and did not speak about the military operations there.

While praising Brazil for its transformation into a thriving and increasingly affluent country, the president repeatedly emphasized the importance of democracy and human rights.

“We all yearn to choose how we are governed. And we all want to shape our own destiny,” he said. “These are not American ideals or Brazilian ideals. These are not Western ideals. These are universal rights, and we must support them everywhere.”

The president said that the struggle for those rights has unfolded across the Middle East and North Africa. “Across the region, we have seen young people rise up – a new generation demanding the right to determine their own future,” he said.

The president said that both Brazil and the United States know from experience that change is driven by the people and “change is not something that we should fear.”

White House officials went to great pains to show that the president remained closely engaged in the Libya crisis. He held a conference call early Sunday with Secretary of State Hillary Rodham Clinton, Secretary of Defense Robert M. Gates and national security adviser Thomas Donilon, who is on the road with Obama.

“I think what you’re seeing today and in this trip is the importance that we place, and that the president places, on the relationships in the Americas,” Dan Restrepo, the senior director for Western Hemisphere Affairs at the National Security Council, told reporters in Rio on Sunday. “The world obviously is a complex place, with a lot of things going on at once, but it’s precisely that, a lot of things going on at once.”

To be sure, the president’s speech, and his whirlwind tour of the most Brazilian of cities, was designed to forge closer ties to a country that was once considered a lumbering giant but that in recent years has seen its economic and diplomatic stature rise. Brazil is now the seventh-largest economy in the world, with an international agenda that includes peace-keeping efforts in Haiti, food aid in Africa and efforts to nudge peace talks between the Israelis and Palestinians.

In the last decade, Brazil has seen more than 30 million people lifted into the middle class.

The president got a quick look at the improvements, even to the most disenfranchised, during a morning visit to City of God, a once-notorious slum, or favela, that officials now hold up as a symbol of a rejuvenated country.

“For the first time, hope is returning to places where fear had long prevailed,” Obama said in his speech. “I saw this today when I visited Cidade de Deus — the City of God. It isn’t just the new security efforts and social programs. It’s also a change in attitudes.”

The welcome offered in Brazil for Obama has been warm. Hundreds waited for him outside the theater on Floriano Peixoto, a huge public square in downtown Rio. When Obama began to speak inside the theater, people crowded around televisions in restaurants on the square to listen.

“This is very important for this country and other countries,” said Joao Paulo Medeiros, 27, who listened as Obama spoke. “There’s great expectations about all these themes here.”