By Elias Biryabarema and Edmund Blair
KAMPALA (Reuters) - Ugandan police on Thursday detained for several hours a former prime minister who has challenged veteran President Yoweri Museveni by seeking the ruling party's nomination in the 2016 presidential election.
Amama Mbabazi, sacked by Museveni last year, was detained on his way to Mbale town, east of Kampala, to meet supporters on Thursday morning and freed late in the evening, an aide said.
His aides said he had been promoting his bid for the National Resistance Movement's nomination in Mbale. Police had banned him from holding meetings, saying no campaigning was allowed until the party chose its candidate.
"He has to stick to what the law requires," police commander Andrew Felix Kawesi told Uganda's NBS television after his arrest. "There's no going to Mbale."
Highlighting rising tension before the presidential and parliamentary votes expected early next year, opposition presidential hopeful Kizza Besigye was also detained in the morning before being freed later in the day, his spokesman said.
Besigye has frequently been held by police for short periods since he championed a series of anti-government demonstrations following the 2011 election that prompted a government crackdown in which at least nine people were killed.
Opposition parties, including Besigye's, have said they will field a single candidate this time.
The opposition say free speech is stifled, votes are rigged and state institutions are used to support Museveni, who has been in office for three decades. The government dismisses the charges and insists it will ensure fair elections.
Museveni, 70, is expected to win again, helped by a big rise in state spending this year, but analysts say the challenge from Mbabazi, 66, a former ally who still commands a following in the ruling party, may be his toughest yet.
"The Mbabazi campaign will continue whether the police want to stop it or not," Mbabazi's spokeswoman Josephine Mayanja-Nkangi told Reuters. She later confirmed his release.
Some Western donors have criticized Museveni for holding on to power for so long, but have also praised the rebel-turned-statesman for stabilizing Uganda after taking power in 1986 and sending Ugandan troops to fight Islamist militants in Somalia.
Besigye, who has lost three elections to Museveni, had been detained on his way to a meeting with the U.S. ambassador, his aide Francis Mwijukye told Reuters.
Without giving details, police spokesman Patrick Onyango said: "He claimed he was going to the American Embassy but we know he had other motives which would lead to breaking of the law so we arrested him."
(Editing by Andrew Roche)