Gabonese opposition leader Jean Ping has demanded a recount after incumbent President Ali Bongo was declared winner of a knife-edge presidential election in the West African nation.

Loud explosions and gunfire could be heard in the Nkembo neighbourhood of the capital Libreville on Thursday, witnesses said, as security forces clashed with angry Ping supporters.

Speaking to Al Jazeera from Libreville, Ping said the result was "a joke".

"Everybody inside and outside the country knows that I'm the winner. There is no doubt about that. All the European observers know that," Ping said.

"That man [Bongo], I believe, is used to cheating, always. And the population is not accepting this type of remake of cheating every seven years," the opposition leader added.

"What we are asking is, under the supervision of the international community, to count ballot by ballot, bureau by bureau. And then you will see that the margin is so big that he cannot win. It's as simple as that."

The Reuters news agency reported that rioting had erupted in at least nine different suburbs of the capital on Thursday, citing witnesses and a police source.

As the violence spread, France called on the government of the former French colony to release details of local vote tallies after the claims of rigging.

"The election result must be perfectly clear and transparent," French Foreign Minister Jean-Marc Ayrault said on RMC radio, adding that the election results should be published bureau by bureau.

READ MORE: "We've never seen results like this, even in the father's time"

Overnight on Thursday, security forces attacked the opposition headquarters in Libreville, Ping said, wounding several people.

"The presidential guard plus some mercenaries and the police, after 1am, bombed my headquarters. They destroyed everything, and we have now two deaths and several people injured."

Bongo won 49.80 percent of Saturday's vote against 48.23 percent for Ping, a narrow margin of only 5,594 votes of a total 627,805 registered voters.

Fires and explosions

Moments after the poll results were announced by the interior ministry on Wednesday, anti-government protesters shouting "Ali must go!" tried to storm the offices of the election commission.

Later on Wednesday the country's parliament building was partially set on fire.

Al Jazeera's Catherine Soi, reporting from the electoral commission compound in Libreville, said Ping's camp would not accept the result.

"Protesters came right outside this compound, many of them lighting tyres and chanting anti-government songs," she said.

"They were dispersed by the police," she said, adding that explosions could be heard in the distance.

Earlier, clouds of smoke and tear gas could be seen over parts of the city where clashes were taking place.

By nightfall, protesters vented their fury by setting fire to the parliament building, sending skyward a plume of flames and black smoke, witnesses and AFP news agency correspondents said.

Fires were visible in other parts of Libreville and explosions were heard as protesters faced off against heavily armed security forces.