(Updates to add reporting credit)
By Katharine Houreld
ISLAMABAD, Aug 13 (Reuters) - Thousands of riot police sealed off Pakistan's capital with barbed wire and shipping containers on the eve of the country's Independence Day, in a bid to foil mass protests aimed at toppling embattled Prime Minister Nawaz Sharif.
Two groups, led by cricket star turned opposition politician Imran Khan and fiery cleric Tahir ul-Qadri, plan to converge on Islamabad on Thursday intent on forcing Sharif to call an early election little more than a year after his landslide victory at the polls.
Police said on Wednesday that they had detained some 2,100 followers of the two populist opposition figures in the past few days, and with all the obstacles in their path it was uncertain how many protesters would reach the capital.
The latest challenge to Pakistan's fragile democracy will inevitably sow unease among neighbours and allies. They dread instability in the nuclear-armed state, which is battling an internal Islamist insurgency and is home to several virulently anti-Western and anti-Indian militant groups.
While police and paramilitary manned barricades round the city, how far Khan and Qadri succeed in destabilising the government could ultimately depend on the stance taken by a military with a long history of mounting coups.
The protesters insist they are reformers crusading against corruption and say last year's election was fraudulent, whereas Sharif's loyalists accuse them of being a front for darker, anti-democratic forces.
While the political temperature has become more feverish, Pakistan's generals have stayed silent. Exchanges of fire between Pakistani and Indian forces on the ceasefire line that acts as a de facto border in the disputed Kashmir region have added to the tension.
Many analysts doubt whether the military wants to seize power, but there is a widespread perception that it could use the opportunity to put the civilian government under its thumb.
"The idea was to put pressure on our government and it has worked," a minister in Sharif's cabinet told Reuters, requesting anonymity.
"Once this is over, things will be a lot more difficult for the government. The decision-making space will be reduced. It is unfortunate that anti-democratic forces have pushed things to this point."
Speaking to journalists in Lahore on Monday, Information Minister Pervais Rashid was more direct, accusing a former "spymaster" of coordinating the security for Khan's protest.
Pakistani media identified him as Ahmed Shuja Pasha, who retired as head of the military's feared Inter-Services Intelligence (ISI) Directorate two years ago.
Neither Pasha or Khan were available for comment.
Sharif and the military have an unhappy history. His last term in office ended in 1999, when then army chief General Pervez Musharraf launched a coup that heralded a decade of military rule.
Since returning to power, Sharif has been at odds with generals who seemed happy to leave running Pakistan's rickety economy to civilians but jealously guard their dominant influence over internal security, defence and foreign affairs.
Relations with the military quickly soured when Sharif's government prosecuted Musharraf last year for treason, angering officers who see the army as Pakistan's saviour and despise politicians like Sharif as corrupt.
Recently Sharif has relented. Musharraf's prosecution ground to a halt and he was released from house arrest, but he remains unable to leave the country.
For all the conspiracy theories over the brewing crisis, Sharif's loyalists have, however, avoided spreading suspicion over serving generals, and the government last month entrusted security in the capital to the military.
"There may be individuals involved in this (protest), friends of Musharraf, perhaps. But we don't see any evidence that the army as an institution is involved," said Ahsan Iqbal, the secretary-general of Sharif's party.
Both Khan and Qadri have also repeatedly denied having secret military support.
"I am not saying call in the army," Khan said on a televised speech Monday. "The army is not the solution."
A military spokesman did not return messages but the military has often said it does not meddle in politics.
So far the government's response to the protests has been a mixture of carrots and sticks.
Qadri, who controls a network of religious schools and charities, has met with stiff opposition. He has a history of organising protests. Last year, he returned from his home in Canada to lead tens of thousands of followers who camped out on the capital's main street for four days.
The cleric had planned to hold another protest in the eastern city of Lahore on Sunday but was thwarted by mass arrests of his followers. Supporters on their way to Sunday's protest were blocked. For two days, they clashed with police in several cities. Eleven people were killed and hundreds injured.
Khan's supporters are considered less likely to fight. His party has urged them to be peaceful, in contrast to Qadri, who urged supporters to retaliate if police attacked.
On Tuesday, Sharif offered Khan a Supreme Court investigation into the alleged electoral irregularities. Khan rejected the offer unless Sharif stood down. (Additional reporting by Mehreen Zahra-Malik and Syed Raza Hassan in Islamabad, Mubasher Bukhari in Lahore and Asim Tanveer in Multan; Writing by Katharine Houreld; Editing by Simon Cameron-Moore and Clarence Fernandez)