Zanzibar's President Amani Karume has been re-elected after Sunday's poll, the election commission has announced.
Amani Karume was always confident of keeping his job
Opposition candidate Seif Hamad has rejected the results, claiming widespread fraud and vowed to carry out threats of Ukraine-style protests.
Earlier, police and opposition CUF activists clashed for a third day on the semi-autonomous Tanzanian islands.
The police fired tear gas and beat CUF activists outside their party base in Zanzibar's historic Stone Town.
The BBC's Noel Mwakugu in Zanzibar says hundreds of opposition supporters kept an overnight vigil before the police moved in, firing tear gas.
Police were seen beating them with sticks and Red Cross workers said they had taken at least 30 injured people to local hospitals - some had been hit by rubber bullets.
Reuters news agency reports that the CUF activists responded by throwing stones and lighting fires on the streets.
Mr Karume got 53% against 46% for CUF (Civic United Front) candidate Seif Sharif Hamad, said Zanzibar Electoral Commission chairman Masauni Yussuf Massauni.
"According to the law, I declare and announce that Amani Abeid Karume has been elected as the Zanzibari president," he said.
Mr Karume's ruling CCM (Chama Cha Mapinduzi) has also retained its majority in the legislature, with 30 seats against 19 for the CUF. One seat will be rerun.
"They doctored the results," Mr Hamad said, claiming CCM supporters were bussed in to CUF strongholds to vote illegally.
"The ZEC has planted Zanzibar into another political crisis," he said. "We are not accepting [the results], we are going to demonstrate at a date that will be determined later."
Before the elections, Mr Hamad said that if the vote was rigged, he would call massive street protests to oust the government - as seen in Ukraine last year.
The claims of fraud were denied by both the CCM and the electoral commission.
Third time unlucky
As well as casting their ballots for a president for the islands, voters were choosing 50 members for the legislature and 139 local councillors.
Mr Karume was running for a second term after winning elections in November 2000, while Mr Hamad was runner-up in Zanzibar's 1995 and 2000 presidential elections.
There were also clashes after the 2000 elections, with the CUF crying foul.
Nationwide voting across Tanzania has been postponed until 18 December due to the death of opposition vice-presidential candidate, Jumbe Rajab Jumbe.
Did you witness the violence in Zanzibar town? Send us your experiences using the form below.
If you would be willing to speak to the BBC News website about your experiences please include a telephone number. It will not be published.
Yes I have been seeing violence fuelled by political zealots purported to be members of the opposition party CUF. In fact the tensions in Zanzibar are historical. The government knew that there could be some people who will defy order, that is why unprecedented security measures have been taken to ensure that there will be no major chaos as it was the case in January 2001.
Kizito Makoye, Tanzania
I am a 68-year-old women who voted in the Stone town of Zanzibar, what I witnessed at the polling booths by the hands of CUF have left me horrified and in shock. I am a women of Arab descent and am married to an African, my husband was refused the right to vote simply because he is of pure African blood. My children and I were humiliated by CUF supporters who referred to my children as illegitimate and branded me a whore.
Amina Awadh, Zanzibar Tanzania
I have seen the police beat the CUF supporters, and to be honest they deserve it. Why does Seif Shariff insist on announcing his own results? This is the job of ZEC. He does this knowing that it will only cause unrest. How can I feel pity for them when there own party leader does not.
Mussin A Ahmed, Stone Town, Zanzibar
Police have done good job, even I see CUF being hit. I am happy because they do not want peace and fair elections. They can stay home and wait for result.
Hamisi Bandari, Stone Town, Zanzibar
I was on Creek Road where one of the riots was. I think the police did the right thing in dispersing the CUF hooligans. It's not fair that a handful of people should cause problems for one million others. I hope they announce the result and we move forward so that I can open my shop.
Abeid Omar Awadth, Zanzibar Town, Zanzibar, Tanzania
The riots were just around the corner from where I live in Forodhani. Where I voted. It's sad that CUF would cause all these problems. I stopped voting for them in 2000 when I realised that they don't know what free and fair means.
Joshi Patel, Stone Town, Zanzibar
The BBC may edit your comments and not all emails will be published. Your comments may be published on any BBC media worldwide.