Police officers patrol outside a polling station in Mtoni, Zanzibar, on Wednesday.

An opposition presidential candidate in Zanzibar detained as he tried to vote early on Tuesday has been released, after nine people were shot dead by security forces ahead of Wednesday’s elections, according to his party.

Zanzibar, an Indian Ocean archipelago, is a semi-autonomous state of the East African country of Tanzania and both are due to elect their presidents and lawmakers in Wednesday’s election.

Tanzanian President John Pombe Magufuli, whose government is accused of muzzling political dissent and independent media – accusations officials deny – is widely expected to win over his rival, Tundu Lissu, and secure another five-year term.

In a statement early on Tuesday, the ACT-Wazalendo party said its veteran candidate for Zanzibar’s presidency, Seif Sharif Hamad, was detained at a polling station after going to cast his ballot in advanced voting.

The party tweeted later in the day that their leader had been released.

It also said nine people had been shot dead by security forces since Monday. Eight died on the island of Pemba, it said, after clashes between security forces and people who had been trying to stop the army distributing ballot boxes on Monday which they suspected contained pre-ticked votes.

ACT-Wazalendo said police fired tear gas at the demonstrators and then “resorted to live ammunition”.

Police said they had no information about any deaths.

Tanzanian police chief Simon Sirro told reporters some youths had been arrested in the incident. “Yesterday … there were youths who started violence when we were offloading ballot boxes; they started throwing stones,” he said.

Zanzibar has a history of contentious elections that in the past have deteriorated into violence. In one such episode in 2001, more than 35 people died.

US Ambassador Donald Wright voiced alarm over “reports from Zanzibar and elsewhere of violence, deaths and detentions”.

“It’s not too late to prevent more bloodshed! Security forces must show restraint, and the NEC (National Electoral Commission) & ZEC (Zanzibar Electoral Commission) must carry out their duties with integrity,” he said in a Twitter post.

On the eve of the election and on election day, some Tanzanians reported disruptions when trying to access social media platforms – accounts confirmed by Twitter and Internet blockage monitor NetBlocks, which reported widespread problems.

President Magafuli’s main opposition challenger, Lissu of the Chadema party, also accused the government of voting irregularities at polling stations.

“It appears thousands of polling agents have either been prevented from accessing polling stations or been kicked out of the polling stations after voting started,” Lissu told CNN in a phone interview.

Observers at Tanzania Elections Watch, a regional initiative, also leveled similar allegations saying polling agents have been blocked in many places throughout the country.

“If we don’t have agents we will not accept any result that is not free, that is not fair, and that is not credible,” Lissu added.

The leading opposition candidate has called on Tanzanians to reject any unfair outcome. “If the integrity of the elections is undermined or jeopardized, the people should take mass democratic action and protest country-wide.”

A government spokesman did not immediately respond to a request for comment.