A Ugandan presidential candidate who called the country’s leader a dictator was arrested during a chaotic election day Thursday following an apparent shutdown of social media sites and fights at polling stations, an aide says.

Shawn Muburi, who is in charge of communications for Kizza Besigye's Forum for Democratic Change party, said Besigye was arrested late Thursday in the Kampala suburb of Naguru, where he had gone to investigate alleged ballot stuffing in a house run by the intelligence agencies.

He said Besigye was arrested and taken to an unknown location and police did not respond to requests for comment.

Besigye is Ugandan President Yoweri Museveni's main challenger in the polls.

Amid tardy delivery of voting materials, Ugandans tried to cast ballots Thursday in presidential and parliamentary elections, with tempers sometimes boiling over.

A top international election observer called the delays "worrying" while the main opposition party said they were deliberate, aimed at favoring Museveni.

Even at noon, five hours after voting was supposed to start, some polling stations in the capital, including a major one, still had not received any voting papers. People had formed long lines and ballot boxes had arrived mid-morning, but still there were no ballots, so no one could vote.

Museveni faces a strong challenge from Besigye, who has called Museveni a dictator and said he doubts that voting will be free or fair.

In Kampala's Ggaba neighborhood, hundreds of people waited for seven hours for one polling center to open before voting papers finally arrived. When the people found out there were ballots only for choosing members of parliament, with no ballots for the vote for president, they overpowered the police, grabbed the ballot boxes and threw them all over the field at the polling station. Police fired tear gas, leading polling officers to abandon the station with no votes cast.

"If the election is free and fair we will be the first people to respect it, even if we are not the winner," Besigye said Thursday at a polling station in his rural home of Rukungiri. "But where it is not a free and fair election then we must fight for free and fair elections because that is the essence of our citizenship."

In Kampala, the spokesman for Besigye's party, the Forum for Democratic Change, said the delays were a "deliberate attempt to frustrate" voters in urban areas where Besigye is believed to be very popular, especially Kampala and the neighboring district of Wakiso.

"Why is it that in areas where we enjoy massive support, like Kampala and Wakiso, that's where these things are happening? We can't have a credible election under this environment," said Ssemujju Nganda.

Many people complained of an apparent shutdown of social media sites like Twitter and Facebook when they couldn't open those sites on their computers and phones.

Godfrey Mutabazi, the head of the Uganda Communications Commission, said the network failure was likely due to an ongoing operation to contain a security threat.

"It's a security matter and I cannot answer on behalf of security," he told The Associated Press.

Speaking to reporters after voting in the western district of Kiruhura, Museveni said the shutdown of social media sites "must be steps taken by security" in anticipation of certain threats.

But Sarah Jackson of Amnesty International said in a statement: "The Ugandan government's decision to block access to social media on mobile phones on election day is a blatant violation of Ugandans' fundamental rights to freedom of expression and to seek and receive information."

"Without clearly defined security concerns, this closure is nothing but an exercise in censorship as Ugandans elect their leaders," said Jackson, Amnesty International's deputy regional director for East Africa, the Horn and the Great Lakes regions.

Museveni said security forces would deal with those who threaten violence during and after the election. Those who arrive at polling stations in time should be allowed to vote, he said.

Later the electoral commission said voting had been extended from 4 p.m. to 7 p.m. for voters in the Kampala and Wakiso districts.

More than 15 million people were registered to vote, for members of parliament as well as president. Many waited under the hot sun to vote at polling stations that at mid-day were still not functioning.

"These cases are worrying because every citizen of Uganda has the right to vote," said Eduard Kukan of Slovakia, chief of the European Union's election observer mission. "And if they are prevented by this kind of method then it would have to be criticized, because it would mean that they didn't manage organizing of the elections the right way."

Some ballot boxes had missing lids. Voting officials frantically made calls.

"We are late simply because the lids for ballot boxes are not here. The boxes and the lids should have arrived at the same time," said Moses Omo, an official who was presiding over voting at a Catholic church in the central Ugandan district of Wakiso.

Many of those waiting said they would not leave without voting.

"This is very disappointing but I am going to stay here under the sun until it is my turn to vote," said Fred Mubiru, a taxi driver. "Nothing will discourage me."

Museveni, 71, came to power in 1986 and pulled Uganda out of years of chaos. He is a key U.S. ally on security matters, especially in Somalia. But his critics worry that he may want to rule for life, and accuse him of using the security forces to intimidate the opposition.

Besigye, 59, is running for the fourth time against Museveni. He promised a more effective government, vowing to stem official corruption.

The Associated Press contributed to this report.