Want smart analysis of the most important news in your inbox every weekday along with other global reads, interesting ideas and opinions to know? Sign up for the Today's WorldView newsletter.

Pakistanis will cast their ballots on Wednesday in national elections that have been clouded by acrimony and violence. A string of suicide blasts have led to dozens of deaths at campaign rallies. Former prime minister Nawaz Sharif and his daughter Maryam were sidelined by corruption convictions that many Pakistanis say were politically motivated, while activists warned that a host of candidates were compelled to switch parties, and journalists and media outlets were intimidated and silenced. Amid the chaos, a glut of extremist Islamist candidates entered the field, a worrying sign of the country’s political drift.

The run-up to the election has been defined by “blatant, aggressive and unabashed attempts to manipulate” the result, declared Pakistan’s Independent Human Rights Commission.

The apparent beneficiary of much of those efforts has been the once-fringe party of Imran Khan, a dashing cricket star turned nationalist politician. And the hidden power believed to be paving the way for Khan’s victory is Pakistan’s military.

The country’s top brass has a long history of intervening in Pakistani democracy. Pakistan’s generals have run the nation several times over the past seven decades; when not openly in power, they have exerted outsize control over foreign policy, the economy and local politics. The ISI, the military’s shadowy and influential intelligence wing, continues to maintain ties with militants abroad while stifling civil society at home. And though this election will mark the third consecutive transition of power from one civilian government to another — a success story by Pakistani standards — it has the fingerprints of military meddling all over it.

A suicide attack in Quetta, Pakistan, on July 25 killed at least two dozens people near a polling station on general election day. (Reuters)

The military’s guiding hand is visible in the partisan judiciary that went after Sharif, who now languishes in jail with his daughter. It is also seen in the cowing of major Pakistani media outlets, including the respected English-language daily Dawn and independent broadcaster Geo TV. In recent weeks, as Sharif’s party staged massive rallies in the province of Punjab, home to more than half the country’s population, Pakistanis had to turn to social media to find any images of the event.

A host of prominent retired military officers have rallied behind the 62-year-old Khan. The charismatic, Oxford-educated former playboy has morphed into a pious nationalist since entering politics, decrying the “toxicity” of the West and the decadent detachment of his rivals. He sees both Sharif’s Pakistan Muslim League-N and the center-left Pakistan People’s Party of late prime minister Benazir Bhutto as corrupt, dynastic factions embezzling the nation’s wealth.

Much like India’s Narendra Modi or Turkey’s Recep Tayyip Erdogan, Khan channels the exasperation of the country’s conservative middle classes and trains his ire on secular elites.

“Liberals are thirsty for blood. They have absolutely no idea,” Khan told British journalist Ben Judah earlier this year. “They sit in the drawing room. They read the English-language newspapers which bear very little resemblance to what is real Pakistan. I promise you, they would be lost in our villages.”

But even with the scales now tipped in his favor, Khan is no shoo-in. The PPP is expected to do reasonably well in Bhutto’s native Sindh province. Sharif’s incarceration — and the abiding sense that the military is still calling the shots — has galvanized support for his party, particularly in his native Punjab. If Khan’s Movement for Justice party ends up with a majority of parliamentary seats, it will have to reverse Sharif’s momentum there.

Either way, many Pakistanis expect an acrimonious aftermath. “Anything but an overwhelming victory by either side is likely to be marred by allegations of fraud and a struggle for control of the government,” my colleagues reported, “pulling attention away from a foundering economy, a looming debt crisis and foreign policy concerns that include U.S. attempts to end the war in neighboring Afghanistan.”

Close to 400,000 troops will be deployed at polling stations to prevent terrorist attacks, but that has raised even more suspicions. “Such a show of force is cause for concern among those who believe the military is seeking to manipulate the election, a belief bolstered by recent reports that some candidates with the Pakistan Muslim League-N and the Pakistan People’s Party have been harassed by security forces or pressured to switch political loyalties,” The Washington Post reported.

Husain Haqqani, a former Pakistani diplomat who now lives in Washington, told Today’s WorldView that the military’s ability to wholly control Pakistan’s civilian leadership has faded. “The way I see it is the military is panicking,” he said. Their attempts to gain back power may create more havoc.

“There is a higher likelihood than there has been in the past that this could end up in a political crisis that makes governance virtually impossible,” Moeed Yusuf, a South Asia expert at the U.S. Institute for Peace, told The Post.

Beyond preserving its extensive economic interests, the military leadership sees itself as the custodian of the nation, one still defined by its birth in the bloody partition of the Indian subcontinent. “They have convinced themselves over years that India is an eternal enemy and that they are the only saviors of the country,” said Haqqani, an outspoken critic of the army who now lives in de facto exile. “They still have this general suspicion of civilians.”

Many analysts contend that this view of Pakistan — and the military’s role in it — leaves the country in a permanent cycle of political tumult and economic stagnation. All the while, Pakistan is growing more and more beholden to Chinese interests and indebted to investment and infrastructure projects run by Chinese state companies — hardly a healthy state of affairs for its democracy.

Sharif, once also the anointed candidate of the military, is by no means an exemplary democrat. But his party’s success in this election would raise new headaches for the top brass, including whether to release him from prison. Cyril Almeida, a prominent Pakistani columnist, suspects the military will find a new accommodation to its satisfaction no matter the outcome.

“A section of the public and politics has been primed to loudly cheer [Sharif's] incarceration; the section of the people and politics that may lean against incarceration can be drowned out; and the few quaint, democratic types left can be easily suppressed,” Almeida wrote in Dawn. And if the public mood compels Sharif's release? “Well, then cut a deal with him, let him out again and start the cycle all over again. Heads they win, tails everyone else loses.”

Want smart analysis of the most important news in your inbox every weekday along with other global reads, interesting ideas and opinions to know? Sign up for the Today's WorldView newsletter.