An opposition call for a mass boycott of presidential elections in Algeria appeared to have succeeded on Thursday, as polls shut after a day marked by mass demonstrations, police clashes and a wave of arrests.

The turnout in the election appeared to be around 20% – a victory for the country’s pro-democracy protest movement, which has derided the vote as a sham.

Tens of thousands of people took to the streets in cities across the former French colony on Thursday, chanting “no to elections of shame” and “generals into the dustbin”.

The poll and its legitimacy is a crucial trial of strength pitting the ruling party and powerful military, who hope it will end months of protests and instability, against an informal coalition of protesters.

The Hirak opposition movement, which has mounted weekly demonstrations since the ousting in April of Abdelaziz Bouteflika after two decades in office, said the poll is a ploy to protect the interests of the political establishment.

In the capital Algiers, protesters shouted “no vote! We want freedom!” as they marched through the city centre. Some clashed briefly with riot police and dozens of arrests were reported. There were also an unknown number of detentions following raids on cafes and offices used by opposition activists.

All five candidates seeking election have been rejected by protesters as “children of the regime” of Bouteflika, and turnout is expected to be extremely low.

“It’s tense everywhere, there are a lot of police in the streets,” said Hamza Zait, a journalist and political analyst in Algiers. “It’s obvious that this [election] is not what we want. But they’re insisting on holding an election in these conditions. The level of participation is very modest for the moment.”

In the north-eastern city of Tizi Ouzou and the coastal city of Oran, there were baton charges and the teargas was fired.

Facebook Twitter Pinterest Dozens of arrests have been reported amid baton charges. Photograph: AFP via Getty Images

The 61,000 polling stations are scheduled to close at 7pm local time and the result may not be announced until Friday. Some had reported that up to 30% of eligible voters had cast their ballots by mid-afternoon but there were much lower turnouts at many other stations, officials said.

Whoever wins will struggle to be accepted by the electorate in Algeria, where many see the military-backed regime as inept, corrupt and unable to manage the flagging economy.

“None of the five candidates can hope to be considered legitimate,” said Anthony Skinner, the Middle East and north Africa director at the risk analysis company Verisk Maplecroft. He predicted the vote would be boycotted on a large scale.

In an early indication of mass abstentions, polling stations at Algerian embassies abroad have remained empty since they opened on Saturday, with the few expatriates who did show up and weathered insults from protesters.

Facebook Twitter Pinterest Ballot papers at a polling station in Algiers. Photograph: Mohamed Messara/EPA

Fears of a violent response by the police also kept some protesters at home. Nourhane Atmani, a 20-year-old student who took part in the mass demonstrations held since February along with members of her family, said her relatives had asked her to stay at home, concerned that demonstrators would be violently beaten, teargassed or worse.

“These elections are a mockery,” said Atmani. “People are angry that after almost a year of protests, the government is still going against our will and playing by their own rules. Algerians aren’t against elections, we’re against voting in a rigged system for corrupt officials. So today … people who went down to protest are getting beaten up and scared away.”

The Hirak movement began when Bouteflika, 82, announced in February he would seek a fifth term. Since then, protesters have demonstrated on the streets demanding the total dismantling of the system that has ruled Algeria since independence from France in 1962.

The military high command, which long wielded power from the shadows, has been forced to take a more visible role and has pushed for the election as a way to resolve the political crisis.

The army chief, Ahmed Gaid Salah, who has emerged as Algeria’s de facto ruler, has described opponents of the election as “a criminal gang … full of bitterness and visceral hate for this country” and said he had ordered security forces to stop any planned disturbances of the poll.

A previous poll set for July was scrapped due to a lack of viable candidates, and the interim president, Abdelkader Bensalah’s, term technically ended five months ago.

The candidates have struggled to campaign, with hostile crowds gathering outside poorly attended rallies in heavily guarded venues. Election posters have been torn down. All the candidates have in the past either supported Bouteflika or participated in his government, two as prime ministers and one as a minister.

“The central demand of protesters since the fall of Bouteflika has been for a change in the system, so as to ensure that the same people are not holding the ropes. However, the only reforms have been surface deep,” said Chloe Teevan, an analyst at the Maastricht-based European Centre for Development Policy Management.

Facebook Twitter Pinterest The candidates (from left): Azzedine Mihoubi, Abdelmadjid Tebboune, Abdelkader Bengrina, Ali Benflis and Abdelaziz Belaïd. Photograph: AFP via Getty Images

The army and the National Liberation Front (FLN), the party that won independence from France in 1962 and has ruled ever since, have pledged the vote will be free.

Algerian courts this week handed down heavy jail sentences in high-profile corruption trials for two other former prime ministers, Ahmed Ouyahia and Abdelmalek Sellal. But even those verdicts did little to win over the protesters, who saw the trials as little more than a high-level purge in a struggle between still-powerful regime insiders.