Tens of thousands of protesters rallied in Pakistan's capital, defying pouring rain to demand the prime minister step down in the biggest challenge yet to the country's government.

Former cricket star Imran Khan, who now leads the country's third-biggest political bloc, and a fiery anti-government cleric called for the rallies in Islamabad, focused on making prime minister Nawaz Sharif leave office and holding new elections.

Mr Sharif, who took office just a year ago in the first democratic transfer of power in a country long plagued by military coups, has said he will stay in power, raising fears of possible political instability in the nuclear state.

"I'll sit here and Nawaz Sharif, you decide. You have just one option - resign and hold re-elections," Mr Khan told supporters.

He said that the current leadership was unacceptable. "We do not recognise them, we have to get justice, we have to get freedom from these types of rulers," he said.

Rana Sanaullah, a senior leader of Sharif's ruling party, said the government was ready to investigate allegations of electoral fraud, but ruled out that Mr Sharif could be removed through a rally. Mr Sharif won a landslide election in May 2013.

The protesters left the eastern city of Lahore on Thursday, vowing to march to the capital and camp out there until their demands for a new government are met. Despite the darkness and lashing rain, the crowds swelled as they entered Islamabad yesterday.

Anti-Taliban cleric Tahir-ul-Qadri also reached Islamabad late Friday. He too led tens of thousands of his supporters to bring about what he called a "green revolution". A spokesman for Mr Qadri, Shahid Mursaleen, said the cleric would also deliver a speech to call for Mr Sharif's removal and immediate arrest.

Security has been tightened across the capital amid fears of unrest in a country with a long history of chaotic politics and military coups. Authorities placed shipping containers into the road to block traffic in many areas, disrupting normal life in the city.

Police estimate about 60,000 people were taking part in the rallies.

Mr Khan said a police officer gave him a letter from the provincial Punjab government, warning that the Punjabi Taliban had planned to kill him.

"I thought, if my life has to come to an end, better it goes in struggle to get real independence for the nation," he said.

Yesterday, as the march led by Mr Khan passed through the city of Gujranwala, supporters of Mr Sharif's Pakistan Muslim League-N hurled stones at the convoy, Mr Khan said. He was unharmed.

Mohammed Azeem, a police officer in Gujranwala, about 40 miles from Lahore, said some 200 ruling party supporters clashed with Mr Khan's protesters but that "the situation is under control".

Both Mr Khan and Mr Qadri have vowed to bring one million followers into the streets of Islamabad, a city of about 1.7 million inhabitants.

Pakistan, a nuclear-armed country of 180 million people, has largely been ruled by military dictators since it was carved out of India in 1947. The army still wields great influence in Pakistan, which is battling several militant groups, but has not taken sides in the protests. There are fears, however, that political unrest could prompt the military to intervene.