From Rio's glamorous beaches to a notorious slum to an elegant theater, Obama glimpsed the city's cultural extremes and offered the kind of personal engagement that can pay political dividends for years. Less than one day after announcing U.S. military strikes against Libya's government, Obama made time to kick a soccer ball around with kids in a shantytown.
The competing stories of Obama's itinerary - a war front in Africa, an economic commitment to South America - divided his time in incongruous ways. By morning, he spoke with his security team about the international assault against Moammar Gadhafi's defenses; by night, he stood atop Corcovado Mountain and drank in Rio's storied statue of Christ the Redeemer and the city lights far below.
Meanwhile, U.S. warplanes pounded faraway Libya.
It was all summed up by one image: Obama, adeptly juggling a soccer ball, as his aides helped him juggle his agenda.
In a speech, Obama celebrated Brazil as a place that has shifted from dictatorship to democracy, moving millions into its middle class and embracing human rights. He underlined that point as unrest sweeps the Middle East and north Africa, leading to dramatic change in some cases and violent crisis in Libya.
"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," Obama told an invitation-only crowd inside an ornate hall here.
"No one can say for certain how this change will end, but I do know that change is not something that we should fear," he said. "When young people insist that the currents of history are on the move, the burdens of the past are washed away."
His speech and his whole trip to this region have been overshadowed by the onset of war in Libya. Obama has tried to find a balance of showing command of the war strategy without altering his diplomatic mission or offending his hosts in Latin America.
And on Sunday, he was determined to be with his family, get among the people and feel the culture.
Obama and his family visited the City of God shantytown that gained fame through a movie of the same name. The slum is undergoing a transformation as Rio works to improve the plight of its poorest people and clean up its reputation ahead of hosting the 2016 summer Olympics.
Obama, his wife Michelle and their daughters, Malia and Sasha, watched young children pound on drums and perform a dazzling acrobatic dance. And then all the Obamas took turns at a little soccer, led by the president.
Obama chose a community center in the heart of one of more than 1,000 slums, or "favelas," that dot the urban hills surrounding the city. The tour was designed to illustrate Obama's push for what officials call citizen security, an emerging concern in Latin American countries as they wrestle with narco-crime and poverty.
Dozens of young children pressed up against a chain-link fence trying to get a look at Obama; the president ultimately stepped outside and gave a big wave.
Obama's route to the slum was itself a contrast of life. The president began and ended his day in a hotel that fronted the famed Copacabana beach, where tourists and locals in bathing suits soaked in the sun and watched for his motorcade.
"He is thinking of Rio as more than just the Christ and Copacabana," said Noemia Marinho, a 40-year-old lingerie saleswoman who lives in the slum and had her hair done just for the president's visit. "Maybe our government will look to us more as well."
The president's tour had an underlying goal of endearing him to a diverse and multicultural country where his personal story already makes him popular. Obama is trying to bolster ties to Brazil - and do the same in Chile and El Salvador over the next three days - as way to boost the economic, security and political interests of the United States.
Obama delivered his speech at the Theatro Municipal performance hall that sits on Cinelandia Plaza, a historic square that was the scene of a 1984 protest that set the stage for the eventual end of a 20-year military dictatorship.
Here, once again, Obama made a game effort to connect to the locals. That included making a solid effort at speaking some Portuguese, drawing some cheers and a few wry smiles from the audience.
He thanked those in attendance for showing up despite the fact that a soccer match between two of Rio de Janeiro's biggest rival teams, Vasco and Botafogo, would begin a few hours after his speech. The very mention of the match in soccer-obsessed Brazil provoked a strong reaction from the fans of the competing teams in the audience.
"For so long, you were called a country of the future, told to wait for a better day that was always just around the corner," Obama said. "Meus amigos, that day has finally come."
The speech was originally billed as an outdoor event on the plaza open to all, but U.S. officials decided at the last-minute to move inside as logistics, costs and other concerns mounted. That sharply reduced the ability of many people to see him. It also lowered Obama's profile on a day when the attention back home was focused squarely on the war.
The president ended his stay in Rio with a nighttime walking tour of Corcovado Mountain to the Christ the Redeemer Statue that is the very symbol of the city and one of the continent's most striking images. After their motorcade snaked up the steep road, Obama held his daughters' hands as they walked around the base of the massive steel and stone statue, lit brightly against the night sky, with its open arms over the city.
At one point the family huddled around a map of the southeast panorama. Sasha pointed as she tried to pick out landmarks far below. The private visit lasted mere minutes.
Obama and his family were flying to Santiago, Chile, on Monday morning.
Associated Press writers Jim Kuhnhenn and Juliana Barbassa in Rio de Janeiro and Bradley Brooks in Sao Paulo contributed to this report.