ISTANBUL — Ekrem Imamoglu spent just 17 days as the mayor of Istanbul before the election council of Turkey annulled the vote and forced him from office.

But the short peek he gained into the dealings of the mayor’s office — revealing dozens of cars at his disposal, millions budgeted for officials’ homes, and a city sinking into debt — gave him ammunition in the political battle ahead. He fully intends to use it before the new election on June 23.

The campaign will be an uphill one: He is aiming to wrench Istanbul away from President Recep Tayyip Erdogan, who as president, prime minister and mayor, has controlled the city as a fief for 25 years. Mr. Imamoglu delivered a humiliating blow to Mr. Erdogan with his victory over Binali Yildrim, the candidate of the president’s party, on March 31, but Turkey’s High Election Council wiped away that defeat, making clear that the president who has seemed invincible for so long would continue to fight.

Still, Mr. Imamoglu said that his brief time in office made him determined to expose and put an end to wasteful spending in Istanbul.