YANGON, MYANMAR — The generals predicted that the Americans would come — but not like this.
In the paranoid decades of military rule, members of Myanmar’s junta told diplomats that they feared an American invasion and regime change.
On Monday, there was a large American deployment to Myanmar, but of an entirely different kind. Two jumbo jets carrying President Barack Obama, Secretary of State Hillary Rodham Clinton and their substantial entourage arrived for a six-hour visit. They were greeted by hundreds of people along Yangon’s streets, many of them waving U.S. flags.
“I saw Obama and nearly fainted,” said U Sein Hla Maung, an accounting teacher, who was perched on a hill overlooking the airport. “I’m very excited.”
Across the city there were symbols of how much mistrust has dissolved between the two governments and how much Myanmar has changed over the past two years as it moves from a dictatorship and toward a democracy. There were graffiti tributes to Mr. Obama, and shops sold T-shirts with his image.
“You are the legend hero of our world,” read a large sign in English held by a group of women standing along the road where Mr. Obama’s motorcade passed.
The warm greeting that Mr. Obama received here was partly government pomp and protocol. Hundreds of students in uniform were bused to the airport to line the roads and chanted in unison a rehearsed greeting: “President Obama is warmly welcomed to Myanmar!”
But the hundreds of others who came to greet the president’s motorcade on their own said they were deeply moved by Mr. Obama’s presence.
“We’ve been waiting 50 years for this visit,” said Kyaw Soe Moe, a restaurateur who had stood along the road with two large American flags. “There is justice and law in the United States. I want our country to be like that.”
During Myanmar’s military rule, American flags were taboo and symbols of defiance. On Monday, well-wishers said it was a measure of new freedoms in the country that they could greet Mr. Obama holding the Stars and Stripes.
“America always meant support for democracy for us,” Win Min, a former student activist who was one of two interpreters of a speech Mr. Obama delivered during his visit. “It was the country that had the strongest criticism of the military regime. We looked up to America.”
In 1988, when students and striking workers rose up against military rule, they marched almost daily to the U.S. Embassy. The military put down the uprising in a crackdown that killed many. It has only been 20 months since the junta in Myanmar ceded power to the civilian government of President Thein Sein. Therefore, American flags strewn across the capital, and Air Force One parked at the airport in Yangon, were a novel and somewhat jarring sight.
“There were people in the old regime and there are probably some people in the new government who still fear America,” said U Thant Myint-U, a historian who was in the audience for Mr. Obama’s speech. “They are afraid of what American influence could unleash here.”
Mr. Obama’s visit suggests that the Myanmar government “now has gained a level of confidence,” Mr. Thant Myint-U said.
Some members of the governing party, which is led by former generals of the junta, sought to play down the visit.
“I want to say that America is not the only friend of our nation — China and India are our friends too,” said U Khin Maung Htoo, a member of Parliament with the Union Solidarity and Development Party.
Mr. Khin Maung Htoo also said it was inappropriate for Mr. Obama to have met Myanmar’s president in Yangon instead of Naypyidaw, the capital built and conceived by the military.
The timing of the visit was awkward for Mr. Thein Sein, who flew from a regional meeting of the Association of Southeast Asian Nations in Cambodia to meet Mr. Obama and then flew back to Cambodia immediately afterward.
In his speech at the University of Yangon, Mr. Obama spoke about the changes to the country and offered a “hand of friendship” between two countries that had become “strangers.” The speech was carried live on Myanmar television, but without explanation the announcers stopped simultaneous interpretation in Burmese after several minutes.
Mr. Obama spoke about Myanmar’s continuing ethnic strife and said the country should harness the “power of diversity.” He said that people with his skin color were once denied the right to vote in the United States.
“And so that should give you some sense that if our country can transcend its differences,” Mr. Obama said, “then yours can too.”
On the street outside the university was U Ko Ni, a former political prisoner, who held up a sign: “Welcome Americans. No other nation has full human rights and democracy. We need and want democracy. Do help.”
Wai Moe contributed reporting from Yangon.