Tanzania's governing CCM party candidate John Magufuli has won the presidential election with 58% of the vote, the electoral commission says.
His main rival Edward Lowassa has rejected the official results that gave him 40% of the ballots cast.
The opposition Ukawa coalition candidate earlier claimed he had won with 62% of the vote.
The elections on Sunday were the most fierce the governing party faced after 54 years in power.
John Magufuli, CCM: 8,882,935 votes - 58.46%
Edward Lowassa, Ukawa: 6,072,848 votes - 39.97%
In Zanzibar, elections for the semi-autonomous archipelago's parliament and president were annulled on Wednesday.
Zanzibar's election chief Jecha Salum Jecha said the poll had been marred by gross irregularities, including rigging and physical fights between rival election commissioners.