Ugandan President Yoweri Museveni has been re-elected for a third term by a clear margin, official figures show.
Police and opposition supporters clashed in Kampala
Mr Museveni won 59% of the vote while main rival Kizza Besigye took 37%, the Electoral Commission said. Dr Besigye, who alleges fraud, rejected the result.
Riot police fired tear gas to disperse opposition supporters in Kampala.
Uganda's first multi-party vote in 25 years is seen as a test of its democratic credentials. In general elections the government did less well.
Yoweri Museveni: 59.28%
Kizza Besigye: 37.36%
With 99% of polling stations reporting
Source: Electoral Commission
Police clashed with opposition activists outside the party HQ of Dr Besigye's Forum for Democratic Change.
But no injuries were reported and there have been no major scenes of violence so far, prompting relief among those who recall fierce clashes during 2001 polls.
The BBC's Will Ross in Kampala says Mr Museveni won about 10% less of the vote than he did five years ago and his camp admit the drop in support is a wake-up call.
Our correspondent says Uganda is now in a period of uneasy limbo and it would be no surprise if the election is contested for a second time in the courts.
Mr Museveni won 4,078,911 votes in the presidential election, compared with Dr Besigye's 2,570,603, Electoral Commission chairman Badru Kiggundu said.
Museveni: In power for 20 years
"The commission is satisfied that the missing results will not change the result."
He said 99% of the nearly 20,000 polling stations had reported. Three other candidates had shared just over 3% of ballots cast.
Turnout in Thursday's vote was about 68%, the commission said, despite interruptions from heavy rain at outdoor polling stations.
Dr Besigye said his Forum for Democratic Change (FDC) believed there had been massive fraud in the vote count, which he called "illegal".
"The FDC has taken a decision to reject the results," he told reporters in Kampala, urging supporters to remain calm.
"There is a big variation in the results coming out of our tallying centre from what the Electoral Commission is announcing."
The ruling party denies allegations of fraud. Ofwono Opondo, spokesman for the ruling National Resistance Movement, called the opposition "bad losers".
"It is up to the population of Uganda to decide."
The FDC has cited several irregularities in the conduct of the polls, including the deployment of soldiers near voting booths, allegedly to intimidate its supporters.
The party also alleged that many FDC supporters had been unable to vote because their names were not included on electoral rolls.
EU observers noted problems with the campaign despite improvements overall.
In their preliminary report, the observers said there was no "level playing field", pointing to Dr Besigye's arrest on charges of treason and rape last year.
They also said state-media was biased towards Mr Museveni and his National Resistance Movement.
Chief EU observer Max van den Berg recommended Uganda should reinstate a law limiting a president to two terms.
Mr Museveni changed the constitution to allow him to contest these polls after being in power for 20 years.
As well as choosing between five presidential candidates, the electorate of 10.4m voted for 284 new members of parliament. Several ministers in Mr Museveni's government lost their seats.