As Malaysia adjusts to life under the Pakatan Harapan coalition government, infighting in its most influential constituent party shows just what a challenge the prime-minister-in-waiting Anwar Ibrahim faces in keeping a united front against the dethroned Barisan Nasional.

Pakatan Harapan ended the Barisan Nasional’s 61-year monopoly on power with a shock victory in May’s general election, but amid all the euphoria there have been indications it is struggling to adjust to life in government.

Among these are the all-too-familiar signs of infighting that has gripped Anwar’s People’s Justice Party (PKR) – which holds 50 of the 222 parliamentary seats and is the largest party in the Pakatan Harapan coalition.

The PKR has become bogged down in a divisive competition between two of Anwar’s lieutenants over the position of deputy president. Internal party polling has been marred by allegations of fraud, misconduct, vote tampering and even violence.

If you thought Malaysia’s bitter leadership battles were over …

Rumours of money politics, phantom voters, a hacked e-voting system, and the alleged interference of sitting Prime Minister Mahathir Mohamad have all been exchanged both in traditional and social media.

Each candidate – incumbent Azmin Ali, who served as Anwar’s special officer when Anwar was deputy prime minister, and Rafizi Ramli, a relative newcomer to the world of politics – has accused the other of cheating and each camp blames the other for spreading poisonous claims in the media.

On Sunday, things took a turn for the worse when Azmin claimed victory.

“Thank you to all [PKR] members who came together and reached a consensus to continue a genuine reform agenda,” he tweeted in a statement immediately criticised as premature by the PKR’s outgoing president Wan Azizah Wan Ismail - who is also Anwar’s wife - and other members of parliament, including Wong Chen.

“The official numbers haven’t come out yet so it’s a bit premature to declare victory,” said Wong. “Candidates would do well to respect due process.”

On Monday, Anwar also chided Azmin, saying: “He has the right [to announce], but he knows that the one who should announce [the results is not him]. And he should respect the process.”

Polls had recently shown the two candidates neck and neck; some insiders believe Azmin’s premature claims of victory may reflect a loss of confidence on his behalf.

“Azmin’s allies dominate federal roles, and he has more catchment and access. The fact a relative small fry like Rafizi has shown his mettle has caught him by surprise,” said one party source.

Azmin was claiming victory now so that if he lost he could claim there had been some kind of interference in the vote, according to the source.

His conduct during the contest, the source said, had painted him in a poor light and had angered Anwar, who many speculate is now leaning towards Rafizi.

Asean’s torn over China-US struggle. Will Mahathir lead the way?

The source noted that when Rafizi had lodged a police report saying he had been assaulted at a polling centre, Azmin claimed the attack was staged to win sympathy, taking to Twitter to call his actions “very pathetic”.

“Comments like these are unbecoming of a senior leader and cabinet minister, it was not received well within the party,” said the source.

The friction is not the only fault line to have appeared in the Pakatan Harapan. Anwar and Mahathir are supposed to have an agreement that Mahathir would hand over the reins to Anwar after two years in power, but the opposition has claimed Anwar is no longer happy with the deal and wants to prematurely unseat the elder statesman, who is 93. The opposition also claims that Anwar fears Azmin may have switched his allegiance to Mahathir, complicating the competition between Azmin and Rafizi.

In his campaign, Rafizi has criticised Azmin for being disloyal to Anwar, a claim Azmin has denied. Azmin, who also serves as economic affairs minister, commands a strong voice within the party, and his supporters wonder whether his leadership qualities – as demonstrated in his new federal roles – may have made Anwar fear him as a competitor.

While infighting is familiar to most political parties, Anwar’s PKR has seen more than its fair share.

In 2010, former law minister Zaid Ibrahim quit the then ruling party the United Malays National Organisation (Umno) and joined the PKR, running for the position of deputy president against incumbent Azmin – only to withdraw his candidacy and resign in protest against alleged internal electoral fraud.

In 2014, Khalid Ibrahim, the former chief minister of Malaysia’s richest state, faced a similar trial. He also took on Azmin for the role, and his loss helped relegate him to the political wilderness.

Now, with Azmin appearing to have seen off a third challenger in similarly ugly circumstances, Anwar will have his work cut out to present a united front to voters.

Political scientist James Chin from Tasmania University’s Asia Institute said such infighting was “only supposed to happen with Barisan Nasional ”.

China, Japan are Malaysia’s priorities: Anwar. But Singapore?

“People are surprised at how close the race is – but no matter what the results, the PKR will be divided unless Anwar can pull both sides together after the elections,” said Chin, adding that reports of scuffles at polling centres were worrying, as violence rarely featured in Malaysian politics.

However, some commentators suggest the PKR’s tumultuous history could work in its favour.

“The party has gone through a lot in the last 20 years,” said Member of Parliament Nik Nazmi Nik Ahmad.

“We have experienced a lot more drama than other parties – the arrests of our leaders, a controversial merger with PRM [a small Malaysian party], issues in earlier internal elections. I am not dismissing the possibility of some sort of internal upheaval, but as long as the victor focuses on building up the party as Rafizi has pledged to do, the PKR will maintain its resilience.”