Ugandans voted Thursday under heavy security and an internet blackout in an election pitting veteran leader Yoweri Museveni against a former popstar after one of the bloodiest campaigns in years.

Voting in Kampala took place under heavy military and police presence, with no reports of violent incidents making their way through the communications shutdown.

Uganda
Uganda AFP / STF

Museveni is seeking a sixth term in office, having ruled for almost four decades, and his main rival is singer-turned-MP Bobi Wine, 38, whose popularity among a youthful population has rattled the former rebel leader.

After a campaign marred by arrests, bloodshed and harassment of the opposition and journalists, the internet was shut down on the eve of the election, further fuelling fears the vote would not be free and fair.

Like this: A staff member at Uganda's electoral commission points to a screen displaying how a ballot paper should be marked
Like this: A staff member at Uganda's electoral commission points to a screen displaying how a ballot paper should be marked AFP / SUMY SADURNI

After polling closed, election agents in the Kololo neighbourhood of Kampala opened ballot boxes onto a black tarpaulin and counted each vote aloud as tallying began.

"We wish to salute the people of Uganda for turning up in such high numbers to elect their leaders and also for doing so in a peaceful and tranquil manner," said elections chief Justice Simon Mugenyi Byabakama, at the national tallying centre.

He said voting had been suspended in two constituencies to another date, one where someone had stolen a ballot box, and another where the name of a candidate did not match the ballot paper.

Face time: Masks with pictures of the two frontrunners
Face time: Masks with pictures of the two frontrunners AFP / SUMY SADURNI

Wine said several of his party's polling agents had been arrested, without going into details.

Police spokesman Fred Enanga told AFP there had been "no major cases of violence reported."

Frontrunners: President Yoweri Museveni, left, and musician-turned-politician Robert Kyagulanyi, also known as Bobi Wine
Frontrunners: President Yoweri Museveni, left, and musician-turned-politician Robert Kyagulanyi, also known as Bobi Wine AFP / Sumy Sadurni

Soldiers marched in Kamwokya, the crowded Kampala slum where Wine grew up and is hugely popular, while convoys of riot police patrolled the capital.

Museveni voted in his home district of Kiruhura in rural western Uganda, about 250 kilometres (155 miles) from the capital.

ome 18 million voters are registered for the presidential and parliamentary vote
ome 18 million voters are registered for the presidential and parliamentary vote AFP / YASUYOSHI CHIBA

"He is sure of winning, but he will accept the result of the election so long as they are free and fair," Don Wanyama, the presidential spokesman, told AFP.

Wine is the strongest of 10 opposition contenders. But Museveni has never lost an election, and most observers expect he and his ruling National Resistance Movement will emerge victorious.

Nevertheless optimism was high in the opposition heartland of Kamwokya.

Face time: Masks with pictures of the two frontrunners
Face time: Masks with pictures of the two frontrunners AFP / SUMY SADURNI

"I am here to change the leadership of this nation because for years, they've been telling me they will secure my future. They have not done that," said driver Joseph Nsuduga, 30.

Results are expected by Saturday at 4pm.

Queues at polling station as Ugandans vote in charged election
Queues at polling station as Ugandans vote in charged election AFPTV / Raphael AMBASU

Wine has vowed non-violent street protests should Ugandans feel the election was stolen.

Museveni has warned that using violence to protest the result would amount to "treason".

He has ruled Uganda without pause since seizing control in 1986, when he helped to end years of tyranny under Idi Amin and Milton Obote.

Once hailed for his commitment to good governance, the former rebel leader has crushed any opposition and tweaked the constitution to allow himself to run again and again.

But he is still held in high regard by older Ugandans who remember the relative stability and security that Museveni returned to the country.

"These young people, they want change, but they don't know what Museveni did for us," said Faith Florence Nakalembe, 58.

But her children, also standing in line in Kamwokya to vote, desperately want change.

"For 23 years I have never seen a different president, and I want someone else," said her son, 23-year-old student Saad Mukoone, who was throwing his vote behind Wine.

"Most of the people in government are old, and they don't want to leave."

The runup to polling day was marred by a sustained crackdown on Museveni's rivals and government critics, and unprecedented attacks on the nation's media and human rights defenders.

In November, at least 54 people were shot dead by security forces loyal to Museveni during protests against one of Wine's numerous arrests.

The US, EU, UN and global rights and democracy groups have raised concerns about the integrity and transparency of the election.

Only one foreign organisation, the African Union (AU), has sent monitors, along with an AU women's group.

On Wednesday, the United States, a major aid donor to Uganda, announced it was cancelling a diplomatic observer mission after too many of its staff were denied permission to monitor the election.

On Tuesday, Museveni announced the suspension of social media networks and messaging services like Instagram, Twitter and WhatsApp in response to Facebook closing accounts linked to government officials the tech giant said were spreading misinformation.