AFP, Lahore: Pakistan's former prime minister Imran Khan returned home today after his arrest sparked days of clashes between his supporters and security forces were declared unlawful.

The one-time cricket superstar – who has been tied up in dozens of legal cases since being ousted from power in April last year – was freed on bail and granted protection from further arrests until Monday.

Enraged by his detention, supporters set fire to government buildings, blocked roads and damaged property belonging to the military which they blame for Khan's downfall.

At least nine people died in the unrest this week, police and hospitals have said. Hundreds of police officers were injured and more than 4,000 people were detained, mostly in Punjab and Khyber Pakhtunkhwa provinces, according to authorities.

"The head of the country's largest party was abducted, kidnapped from the high court, and in front of the entire nation," Khan told AFP from the Islamabad High Court after being freed.

"They treated me like a terrorist, this had to have a reaction," he said of the protests that followed.

Khan has repeatedly clashed with Pakistan's powerful military since being booted from power last April in a no-confidence vote and told reporters that "one man, the army chief" was behind his arrest.

Prime Minister Shehbaz Sharif, the head of a shaky coalition, today warned that those involved in "facilitating, abetting and perpetrating" the violence should be arrested within 72 hours.

"Those who demonstrated anti-state behavior will be arrested and tried in anti-terrorist courts," he said during a visit to Lahore.

At least 10 people from PTI's senior leadership have been arrested since the protests began, one of Khan's lawyers said.

Interior minister Rana Sanaullah has repeatedly vowed that police will rearrest Khan, who remains wildly popular ahead of elections due in the Autumn.

The country now seems primed for a "progressively ugly showdown in the days and weeks to come", read an editorial in Dawn, the country's leading English language newspaper.

"None of the leaders, political or institutional, who are invested in this tug-of-war appear ready to take a step back," it said.

Khan returned to his Lahore residence today where he was greeted by jubilant crowds of supporters who threw rose petals over his car.

His arrest on Tuesday came just hours after he was rebuked by the army for claiming it was involved in an assassination attempt against him last year.

Khan won power in 2018 on an anti-corruption campaign, voted in by an electorate weary of decades of dynastic politics.

Independent analysts say he was brought to power with the support of the military – who hold undue influence in Pakistan – before falling out with the generals.

Mobile data services and access to social media platforms including Facebook and YouTube, which were cut shortly after Khan's arrest on Tuesday, had been partly restored around the country.

Pakistani politicians have frequently been arrested and jailed since the country's founding in 1947 but few have so directly challenged a military that holds significant influence over domestic politics and foreign policy and has staged three coups.