Widespread allegations that the military is working behind the scenes to swing Pakistan’s election this week in favour of cricketer-turned-politician Imran Khan are threatening to sully what is only the country’s second democratic transition of power.

The vote on Wednesday is expected to be a two-way race between Khan’s Pakistan Tehreek-e-Insaf (PTI) party and the Pakistan Muslim League-Nawaz (PMLN), the party headed by former prime minister Nawaz Sharif, who is now in jail and has for decades had tense relations with the army. “The military has little desire to see the PMLN return to power,” said Michael Kugelman, a South Asia expert at the Wilson Center in Washington DC, “and it is willing to engineer actions behind the scenes that undercut the PMLN’s electoral prospects in a big way.”

Members of the PMLN have complained of a campaign of harassment and arrests. Many senior leaders say they have been threatened by the military’s intelligence agencies to force them to join Khan’s party. Criminal cases have been opened against nearly 17,000 party supporters, and corruption investigations launched against several senior party members. Members of another major party, the Pakistan People’s party, also allege military officers have pressured their candidates to switch allegiance.

The country’s leading English-language newspaper Dawn, which is considered sympathetic to the PMLN, says its distribution is being blocked. Many journalists and online activists say they are under pressure to promote the PTI and mute criticism of the army or coverage of the PMLN.

The army has directly ruled Pakistan for about half of its history. But journalists, politicians, analysts and rights activists say this is its most brazen foray into civilian life in recent years. “This will be the dirtiest, most dishonest and rigged election that Pakistan’s beleaguered public has ever faced,” journalist and author Ahmed Rashid said. “There is a growing cacophony of voices from major political parties, human rights groups, academics, civil society groups, and minorities that this will turn out to be a fraudulent election.”

The ousted Pakistani prime minister Nawaz Sharif, convicted of corruption, returned to the country earlier this month. Photograph: Aamir Qureshi/AFP/Getty Images

Sharif was ordered to be jailed in a corruption trial stemming from 2016 Panama Papers revelations that showed he had bought expensive London properties through offshore companies. Sharif and his family have called the proceedings a conspiracy, hinting at intervention by the military. The military denies this.

On 13 July, Sharif and his daughter arrived in Pakistan from London to face arrest over the corruption charges. Huge drama surrounded their return as the caretaker government moved quickly against leaders and supporters of the PMLN around the country who tried to hold rallies and travel to Lahore airport to welcome Sharif. In the days before his return, police arrested at least 600 party workers on security-related charges.

“Hundreds have been arbitrarily arrested for the sole reason that they support Nawaz Sharif,” said Omar Wariach, deputy South Asia director for Amnesty. “What was once a vibrant and lively political space has now become suffocatingly small.”

Shahid Khaqan Abbasi, a PMLN leader who took over as prime minister when Sharif was ousted last July, said moves to “engineer” the election began while his party was in government. At one party meeting three months ago, he said almost half those present said they had been approached by people from the military to switch parties.

In a video message released last month, PMLN candidate Rana Iqbal Siraj said he was tortured and threatened by intelligence personnel to give up his support of Sharif. He has since recanted the statement.

In May, as many as 21 PMLN politicians from Punjab province formally joined Khan’s PTI, giving the party a major boost ahead of elections. Earlier this month, more than 11 candidates decided to return PMLN tickets and instead contest under the new “jeep” symbol as independent candidates. The symbol has widely come to be seen as an umbrella grouping for those plied away from the PMLN by the military.

Abbasi’s own nomination papers, like those of several other PMLN members, were rejected and he was barred by an election tribunal from contesting until a higher court finally ruled in his favour.

“So many others have had to jump through all types of hoops, whether against corruption investigations suddenly being opened up, or election officers not accepting our nomination papers,” Abbasi said. “It’s been a brutal and strange affair for our party.” Also recently joinging the race are several religious parties – including one headed by the leader of a banned group that incites violence against minority Shias – who the military has “mainstreamed”, allowing them to abandon their violent pasts and contest elections as potentially useful spoilers to undercut the PMLN.

The last few months have amplified the deep imbalance in civil-military relations Michael Kugelman

Many analysts fear the attempts to rig the election could lead to a hung parliament or a weak governing coalition. “That’s exactly the type of administration the military would want, because a fragile and divided government would be easier to exploit than a united one with a strong mandate,” Kugelman said.

Parties and rights groups are also concerned by the election commission’s decision to deploy 371,000 troops, three times more than 2013, at polling stations, and grant them broad judicial powers, including to hold on-the-spot trials and sentence anyone breaking election laws.

Expanded powers for an army that has topped several governments in the past could have long-term implications for Pakistan’s fledgling democracy. “The damage is already done,” said Kugelman. “The last few months have amplified the deep imbalance in civil-military relations and the soaring challenges Pakistan faces in trying to strengthen civilian institutions and leaders. It will be a tall order, to say the least.”

The army’s media wing did not respond to calls from the Observer, but in a press conference earlier this month military spokesman Major General Asif Ghafoor denied allegations of interference in the election. Fawad Chaudhry, a spokesman for the PTI, rejected claims of pre-poll rigging, and denied the party was being backed by the military. “If Nawaz Sharif had support, no one would leave his party just because they were approached by a colonel or a major from the army,” he said. “The army can coerce a few people but can they make 208 million people vote for Imran Khan? This is a joke.”