Trying to reverse a stinging setback, Turkey’s ruling party on Tuesday demanded a redo of last week’s election for mayor of Istanbul, the country’s largest city and long a source of power and prestige for President Recep Tayyip Erdogan.

The extraordinary stance came as it became increasingly clear that a days-long recounting of ballots would not change the result that Binali Yildirim, the candidate of Mr. Erdogan’s Justice and Development Party, known as the A.K.P., had lost to the opposition candidate, Ekrem Imamoglu, in the March 31 election.

Mr. Erdogan’s party had already demanded a recount of spoiled ballots in all of Istanbul and a full recount in some of the city’s districts. When that did not change the result, it called for a recount of the entire Istanbul vote, which the High Election Council refused.

The latest demand now puts the High Election Council squarely on the spot and threatens to precipitate a crisis for both Istanbul and the entire country, becoming the latest test of democratic institutions already groaning under the authoritarian strains of Mr. Erdogan’s 16 years in power.