This article is more than
3 year old"He is going home. He is free," said Etienne Ndione, one of his lawyers.
Mr Sonko, 46, is accused of assaulting a woman who worked in a beauty salon.
He says the case is politically motivated to stop him running again in elections in 2024. He came third in the 2019 poll with 16% of the vote.
Demonstrators scuffled with security forces outside court in the capital, Dakar, before Monday's hearing.
Police have deployed armoured cars in the city in the wake of several days of clashes in which at least eight people were killed, including a teenager in the southern town of Diaobé - the most serious violence Senegal has seen for several years.
Tear gas was also fired at protesters in central Dakar on Monday, after they pelted officers with stones.
Mr Sonko is popular among young Senegalese, and an opposition collective known as the Movement for the Defence of Democracy has called for three days of mass protests, starting on Monday.
Schools in the capital have also been ordered to close for a week following the unrest.
On Sunday a top Senegalese official whose job is to settle conflicts, Alioune Badara Cissé, said the authorities "need to pause and speak with our youth" and warned that "we are on the verge of an apocalypse".
Mr Sonko's arrest is seen as a "lightning rod for much broader discontent and frustrations," Francois Rouget of security consultancy Control Risks told the BBC's Newsday programme.
"These [protests] come at a difficult economic time - there are lots of frustrations coming from curfews that have been imposed to tackle coronavirus, so we are seeing a lot of convergences in grievances," he said.
Much of Mr Sonko's support comes from the large group of young Senegalese who feel disillusioned about their prospect of finding work.
A lot of the anger is also directed at President Macky Sall, who is being accused of using the judiciary for his political aims.
Two other opposition leaders were excluded from the 2019 election after convictions which they say were politically motivated. Mr Sonko is currently the country's only major opposition leader.
Mr Sonko was accused of rape in February. He was arrested on Wednesday as he was on his way to court, accompanied by a group of supporters, on charges of disrupting public order when he refused to change his route.
A 46-year-old former tax inspector, he was fired in 2016 after making allegations of tax anomalies against the president's brother, Aliou Sall.
Mr Sonko had at that point already become involved in politics, forming his Pastef party in 2014.
His parliamentary immunity was removed last week, after he was accused of rape.
His opponents dismiss him as a demagogue and agitator but he is popular with young people for his pan-African rhetoric and condemnation of France's continued economic role in Senegal.
Mr Sonko grew up in the southern town of Bignona, which has seen some of the worst violence.
France is the largest trading partner and investor in Senegal, and French companies are accused of stifling local-owned businesses.
French-owned supermarket chain Auchan said on Friday that there had been 14 attacks against 32 of its stores across the country.
Other French-owned companies such as Total petrol stations, Air France offices and Orange mobile phone outlets have also been attacked by the protesters, who consider France, the former colonial ruler, a strong ally of President Sall.
Senegal's neighbours in the West African regional bloc, Ecowas, have condemned the violence and called on "all parties to exercise restraint and remain calm" - adding that the authorities should "take the necessary measures to ease tensions and guarantee the freedom to demonstrate peacefully".
The UN and foreign embassies have also appealed for all sides to show restraint.
<p>The deployment of Kim Jong-un’s troops has added fuel to the growing fire in recent weeks. Now there are claims Vladimir Putin has put them to use.</p>