Sharif is locked in a power struggle with Pakistan's president that threatens to paralyze politics in the nuclear-armed country and dilute its focus on tackling economic woes as well as Taliban militants operating along the Afghan border.

Hundreds of police surrounded the former prime minister's residence in the eastern city of Lahore before dawn on Sunday and detained him along with scores of his supporters, a party spokesman said.

Officers showed party officials an order placing Sharif and his politician brother Shahbaz under house arrest for three days, spokesman Pervaiz Rasheed said.

But Sharif later denounced the order as illegal and left the house in a convoy of vehicles packed with chanting, flag-waving supporters, headed for a downtown rally which was turning increasingly violent.

Rao Iftikhar, a senior government official, said authorities had decided to relax the restriction on Sharif so that he could address the rally and return home.

Lawyers and opposition party supporters had planned to gather near Lahore's main court complex before heading toward Islamabad to stage a mass sit-in front of Parliament, in defiance of a government ban.

To thwart them, authorities parked trucks across major roads on the edge of the city, and riot police took up positions outside the railway station and government buildings.

Protesters pelted some of the hundreds of riot police ringing the area with rocks, triggering running clashes. An Associated Press reporter saw one officer led away with a head wound.

Police repeatedly fired tear gas, scattering the crowd, and beat several stragglers with batons, only for the demonstrators to return with fresh supplies or sticks and stones. Mobs accompanying Sharif's convoy smashed the windows of buses parked along the route.