The army’s influence on Pakistan’s election on July 25 was greater than it has ever been. Since its creation in 1947, after the partition of British India, Pakistan has had 30 years of military rule (1958–70, 1977–88 and 1999–2008). But for the past 10 years, the military has stayed in the background, allowing civilian politicians to take turns in power after elections that were always marred to some extent by electoral irregularities.

The 2008 elections had been a two-stage transition to democracy: In February that year the Pakistan Peoples Party (PPP) won the parliamentary election, benefiting from a wave of sympathy after the assassination of Benazir Bhutto, daughter of PPP founder Zulfikar Ali Bhutto; then in August General Pervez Musharraf relinquished the presidency to Benazir Bhutto’s widower, Asif Ali Zardari. In 2013, for the first time in Pakistan’s history, a democratically elected government completed its full term and there was a democratic change of government, with the center-right Pakistan Muslim League-Nawaz (PML-N) succeeding the center-left PPP.

This strengthening of the democratic process was bound to disturb the military, which is often referred to euphemistically as “the establishment” but is also known by its opponents as the “deep state” because of the key role of its intelligence agency, Inter-Services Intelligence (ISI). Not only did the creation of legitimately elected civilian powers threaten to reduce the army’s influence, but some elected PPP and PML-N leaders tried to pursue policies that ran counter to the military’s wishes, especially towards India, which it regards as its principal enemy. Zardari offered to cooperate with India in the investigation into the November 2008 attacks in Mumbai in which more than 160 people were killed. Since a part of Pakistan’s military had been behind these attacks, he had to retract his offer quickly.

Zardari’s successor, Nawaz Sharif (PML-N), who had already been prime minister 1990–93 and 1997–99, was unexpectedly less biddable. Sharif, a businessman whose political career had been launched by the military to challenge Benazir Bhutto, had tried in the late 1990s to free himself from military influence. During his second term, he had made peace overtures to India, since he was convinced that Pakistan was wasting resources in an arms race with its neighbor and that its economy could greatly benefit from bilateral trade links. The 1999 coup was very much an expression of the military’s disapproval of this policy. Sharif did not abandon it when he returned to power in 2013, as shown by his meetings with India’s Prime Mnister Narendra Modi in 2014 and 2015. The military, which permanently opposes normalized relations with India, managed to derail these discussions, because normalization would mean ratifying the partition of Kashmir; this would deprive the military of one of its raisons d’être and reduce its budget.

Panama Papers revelation

As Sharif insisted on setting his own political course, the military worked tirelessly to get rid of him. The international publication of the Panama Papers provided an excuse, as they revealed fraud committed by eight foreign companies registered in the name of the Sharif family. Legal proceedings began and the commission of inquiry, including members of the military, which was created at the request of the Supreme Court, found the prime minister had breached the constitution’s demands for sincerity and virtue from politicians. Its verdict led to his removal from office for corruption in July 2017, a lifetime ban on holding political office, and a 10-year jail sentence.

With Sharif gone, the military needed a replacement. The simplest solution would have been the direct assumption of power, but the military had ruled that out for a decade. Coups often have a high cost in terms of international sanctions and Pakistan depends on foreign donors, especially the International Monetary Fund. The military also had very mixed reactions to General Musharraf’s time in power (1999–2008): Governing means running an economy (his results were poor) and managing a society with multiple tensions.

Rather than getting its hands dirty, the military opted to deploy a figure who would allow it to remain behind the scenes while retaining control of its top priorities: Pakistan’s relations with India, Afghanistan, the US and China. Pakistan has begun a huge $56 billion project with China, the China-Pakistan Economic Corridor, with a main objective of building communications links between western China and the Indian Ocean.

The military needed someone who shared some of its views and was popular enough to get elected, while enabling Pakistan to maintain a democratic facade that would satisfy foreign critics and meet the people’s aspirations for democratic freedom. For 70 years, Pakistan has been affected by a fundamental tension between the desire for a strong regime that can protect it against the (alleged) threat from India, and the desire for democracy, with the result that the military has never managed to establish a lasting dictatorship. Imran Khan, despite his known volatility, was the only man for the job.

Khan’s sporting success had brought him popularity with a significant part of the electorate (in 1992 he had led Pakistan to its only victory in the Cricket World Cup); he was also popular for his philanthropic work, such as the hospital for cancer sufferers he set up, and most of all, for his anti-corruption stance. This has been his key campaign issue since he founded the Pakistan Movement for Justice (Pakistan Tehrik-e-Insaf, PTI) in 1996. The fight against corruption has a double appeal for the military: It appeals strongly to the middle class, who are outraged by the way major families in power (such as the Zardari-Bhuttos and the Sharifs) have enriched themselves, and it discredits leading politicians. Khan and the military share a common enemy: the political class.

Above regional divisions

Khan’s nationalism also created affinities with the military. Unlike his rivals, he was not associated with any one province. Whereas the Bhuttos identified themselves with Sindh and the Sharifs with Punjab, Khan, despite presenting himself as Pashtun (though he doesn’t speak Pashto), belongs to an elite that transcends regional divisions, thanks mainly to his cricketing career. The military, which claims to be a symbol of national unity, is sensitive to this pan-Pakistani identity, not least because it opposes the current trend towards greater federalism. It is against the implementation of the 18th amendment to the constitution, passed in 2010 by the PPP and PML-N, which grants the provinces greater autonomy and more financial resources. Khan’s nationalism also makes him deeply hostile towards India, which he denigrated throughout his election campaign.

His references to religion also appealed to the military, which portrays itself as the national guardian of Islam. Despite his eternal playboy appearance, and a matching lifestyle including two divorces, Khan likes to display his piety and social conservatism. In a 2012 newspaper article, he described how he rediscovered Islam as a reaction against Western materialism, immorality and criticism of Islam during the furor over Salman Rushdie’s Satanic Verses. He claims to see his cricketing victories as Allah’s will. Since then, he has set himself the mission of establishing a dialogue between Pakistan’s Westernized elites and radicals whose intolerance, he says, is alien to Islam.

Though he claims to be a mediator, Khan has come to defend positions espoused by Islamists in the name of tradition, especially family values. He has also supported the strict application of sharia. Since 2013 he has said he is ready to negotiate with the Pakistani Taliban and has been an apologist for their Afghan counterparts, approving of their judicial “system” and their fight against the United States. He gained a reputation as an intransigent nationalist by opposing US drone strikes on the Afghan border after 2010. His election threatens to make relations with Washington—already complicated following President Donald Trump’s announcement of a reduction in US aid—yet more tense.

To attract voters, Khan exploited both his image as a prickly nationalist and as a religiously devout man. He visited the grave of a famous Sufi saint with his third wife, Bushra Maneka (herself divorced, with three children from her first marriage), whom he calls his spiritual guide. His party called on Pakistanis to vote against the PML-N because it was responsible for the execution of Malik Mumtaz Hussain Qadri, who in January 2011 had assassinated the governor of Punjab, Salmaan Taseer. Taseer had been killed because of his opposition to Pakistan’s anti-blasphemy law; its first victims were minorities, especially Hindus, Christians, and the Ahmadis, who claim to be Muslims but believe in a 19th-century prophet. Khan called for the anti-blasphemy law (which has already led to hundreds of men and women being imprisoned) to be applied more severely to Ahmadis because “no Muslim can call himself a Muslim if he doesn’t believe that Mohammed is the last prophet.” This highly sensitive issue had previously only been exploited by the most radical parties.

To support Khan, the military also tried to suppress unsympathetic media (especially Dawn, the main national daily newspaper) during the election campaign. It tried to intimidate journalists, using the threat of tax investigation, and even kidnapping. EU and Commonwealth election observers found evidence of “severe restrictions and curtailment on freedom of expression, which has resulted in extraordinary levels of self-censorship.”

Nonetheless, despite electoral manipulation, the PTI did not achieve an outright majority. It won 115 seats out of 272 on a 32 percent share of the vote, compared to 64 seats for the PML-N (24 percent of the vote) and 43 seats for the PPP (13 percent). Despite the pressure, PML-N leaders still stood for election. The result may also reflect the fact that the military was less keen to anoint Khan than to avoid a second PML-N mandate, or even wanted to engineer a parliament without a majority, which would weaken civilian government in general.

Enter radical Islam

The remarkable results achieved by some political newcomers who had covert support from the military lends credibility to this interpretation. Members of the Islamist movement Lashkar-e-Taiba (Army of the Good), an organization traditionally close to the military, were authorized to put up independent candidates by the electoral commission (which came under pressure). Tehrik-e-Labbaik Pakistan (Here I Am Movement Pakistan), a party formed a year ago to defend sharia (and the assassination of Taseer), won 4 percent of the vote. These new proponents of radical Islam in the political arena are claiming the ground of traditional Islamic parties Jamaat-e-Islami (Islamic Congress) and Jamiat Ulema-e-Islam (Assembly of Islamic Clerics), whose coalition is losing momentum.

The fragmentation of parliament suits the military, but Khan can still form a coalition government that gives him a majority, however fragile. His party also governs two provinces, one of them Punjab, where over half the population lives. Punjab is a trophy the PTI only just managed to wrest from PML-N control; this was a relief for the military, which was worried about the influence of the Sharif family in the province where it recruits most of its officers. Shehbaz Sharif, the brother of the former prime minister, had governed Punjab since 2009.

Will this position of strength allow Khan to pursue his policies or will he have to submit to the military? Nawaz Sharif tried to free himself from the military; Zardari tried to live with it. The new prime minister might seek some as yet uncharted middle way. It will soon be possible to judge on key issues. Khan may have no problem recentralizing the state by diluting the 18th amendment and dividing Punjab into several provinces, as the military wishes, to stop any party’s building a power base in Punjab, which currently returns over half the members of parliament. However, he is likely to have trouble financing his promised “Islamic welfare state” without reducing the military budget (currently 20 percent of government spending, excluding military pensions). There could also be problems if he wants a say on relations with China, which he would like to strengthen further, and with India.

There are other challenges: dealing with the country’s still unresolved financial crisis—which will force Khan to seek IMF help as his predecessor did—and the newfound unity among the opposition, especially the PML-N and the PPP. Khan also has the problem of deciding the fate of Nawaz Sharif: Keeping him in prison risks turning him into a martyr; releasing him could considerably strengthen the opposition, so the solution may be sending him back into exile.