Ugandan opposition leader Kizza Besigye arrived home on Thursday from hospital in Kenya, hours before President Yoweri Museveni was due to be sworn in for a fourth term that will extend his rule to three decades.
Standing through the sun-roof of a car, Besigye and his wife Winnie waved to several thousand ululating supporters who made V-signs for victory amid a heavy security presence along the road leading to Kampala, a Reuters witness said.
Besigye and his supporters have staged a series of protests against rising prices in recent weeks.
Museveni is being inaugurated after a comfortable election win in February which Besigye, the veteran leader's closest opponent, said was rigged. Besigye and other opposition leaders have refused to recognise Museveni as president.
"These multitudes of people have turned out to welcome Besigye because they think he is the only remaining voice through whom they can voice their grievances," said opposition supporter Godfrey Kayongo as Besigye drove past.
An hour's drive away in Kampala, television showed Museveni sitting calmly, giving a thumbs up, as the leaders of Nigeria, Ethiopia, Kenya, Zimbabwe, Tanzania, Democratic Republic of Congo, Somalia and South Sudan rolled up for the ceremony.
Besigye has been arrested four times in Uganda since protests over high fuel and food prices began in April. He had gone to the Kenyan capital Nairobi for medical treatment after being wounded when police detained him two weeks ago.
Museveni, in power for 25 years, has promised to crush the protests, blaming the rising food and fuel costs on drought and global increases in crude oil prices.
Fresh from an emphatic poll win, Museveni has picked a fight with Besigye, confident donors will not criticise his strongman tactics too much because Ugandan troops form the backbone of an African peacekeeping force in Somalia, analysts say.
"As long as Ugandan troops are all that stand between the (Somali government) and its inevitable fate, Uganda's international partners are really constrained in what they can and cannot do," said J. Peter Pham, Africa analyst at the Atlantic Council.
"Museveni knows that as unpalatable as the actions of his regime may be, the donor states cannot afford to turn on him as long as he spares them having to deal with Somalia themselves."
Besigye was Museveni's doctor during the guerrilla war that swept the rebel leader to power in 1986. But the two fell out and have been bitter rivals ever since.
Other regional experts said Museveni, widely regarded as an astute political leader, would be wary of alarming foreign investors developing the east African country's oil reserves.
"Uganda's energy sector is still in an infant stage ... that Museveni must recognise. He is a strong leader who isn't afraid to govern as he sees fit," said Stratfor's Mark Schroeder.
Uganda discovered oil along its western border with Congo in 2006 and commercial production is expected in 2012, bringing a flow of cash that Museveni has promised will be used to develop his poverty-stricken country.
Besigye is expected to hold a prayer meeting with other opposition members in the capital on Thursday.
"I think most of the time I will be at home. There are no special plans. We intend to have a prayer (session) for our country which I will take part in," Besigye told Reuters before boarding the flight from Kenya.