BAGHDAD — Iraq’s Supreme Court on Thursday upheld a disputed law ordering a hand recount of the ballots from last month’s national elections after widespread allegations of fraud embarrassed political leaders and marred the initial result.

What was supposed to mark the start of a new era for Iraq has turned into a political crisis as the charges of vote tampering grew too loud for Prime Minister Haidar al-Abadi’s government to ignore.

The May 12 election was the first since Iraq declared victory over the Islamic State, which was in control of one-third of Iraqi territory just three years ago.

But the euphoria over that milestone was quickly overshadowed by the charges of voter irregularities that surfaced on the day of the election and grew louder in the weeks that followed.

Adding to the outcry was a suspicious fire on June 10, days after Parliament ordered the recount, that burned down a warehouse believed to contain some of the ballots cast by Baghdad voters.