Facebook/Vitaliy Klitschko

When Rudolph W. Giuliani met with a top aide to Ukraine's president last summer, he discussed the prospect of a coveted White House meeting for the president while seeking Ukraine's commitment to certain investigations that could benefit President Trump politically.

Mr. Giuliani also threw in a request of his own: help the mayor of Kyiv keep his job, Ronen Bergman, Anton Troianovski, and Kenneth P. Vogel wrote for The New York Times.

The mayor, Vitaliy Klitschko, a professional boxer turned politician and longtime friend and former client of Mr. Giuliani's, was on the verge of being fired from his duties overseeing Kyiv's $2 billion budget.

Firing Mr. Klitschko would have fit with President Volodymyr Zelensky's campaign promise to fight Ukraine's entrenched interests and allowed him to replace a political adversary with a loyalist in one of the country's most important posts.

But despite the fact that Mr. Zelensky's cabinet approved Mr. Klitschko's removal, he remains there today, leaving his adversaries in the murky and lucrative world of Ukrainian municipal politics to wonder whether Mr. Trump's personal attorney may have tipped the scales in his favor.

"The coincidence in timing between Klitschko's meeting with Giuliani and the developments in the governance of Kyiv was striking," said Oleksandr Tkachenko, a member of the Ukrainian Parliament whom Mr. Zelensky had been expected to nominate as Mr. Klitschko's replacement.

Mr. Giuliani's effort to help his friend and former client, first reported in The Washington Post, shed fresh light on the former New York mayor's mingling of personal, business and political interests with his role as personal attorney to the president of the United States.

Read alsoSBI questions Klitschko as witness in unlawful allocation of land for housing construction

In an interview with The New York Times, Mr. Giuliani acknowledged discussing Mr. Klitschko's position in a meeting with a senior aide to Mr. Zelensky, Andriy Yermak, in Madrid on August 2.

"I said, 'I don't know, I'm from the outside, but he seems like one of the good guys,'" Mr. Giuliani said, recalling the conversation. "'And I'm speaking, speaking, speaking as a personal friend, not as a representative of the government or anything else.'"

In the same meeting, Mr. Giuliani discussed a possible Oval Office visit by Mr. Zelensky that the Ukrainian president had been seeking, and asked for a commitment by his government to pursue investigations into former Vice President Joseph R. Biden Jr., his son, and Ukrainians who disseminated damaging information about Mr. Trump's 2016 campaign.

The meeting took place at a time when Ukraine's new president was looking to cement support from the United States, his country's most powerful ally in the conflict against Russia, and to build a relationship with Mr. Trump.

Mr. Giuliani said that he made it clear that he was relating his personal view of Mr. Klitschko, not that of the administration. "I gave it as my opinion – not the government – and based on our personal relationships," he said.

Mr. Yermak also acknowledged that the two discussed Mr. Klitschko's fate.

"Giuliani asked for my opinion about Vitaliy Klitschko as a mayor," Mr. Yermak said in a statement in response to an inquiry from The Times. "He immediately issued the disclaimer that I should not see his question as an attempt to influence me."

Mr. Yermak said he told Mr. Giuliani that he had long known Mr. Klitschko and that he had the support of Kyiv's citizens.

"That was the end of our conversation about Klitschko," Mr. Yermak said. "As a result I reject any speculation that Mr. Giuliani in any way sought to influence my opinion or to make me accept some narrative regarding Mayor Vitaliy Klitschko."

Given the complex and opaque nature of Ukrainian politics, it is not clear whether Mr. Giuliani’s intervention was the decisive force allowing the mayor to keep his job.

Read alsoFollowing spat with Zelensky Office chief, Klitschko flies to NY, meets with Trump's lawyer

But it is clear that he tried.

Mr. Klitschko, a former heavyweight world boxing champion, first hired Mr. Giuliani as a consultant for his unsuccessful run for mayor of Kyiv in 2008.

Since 2014, Mr. Klitschko has held dual roles: both the largely ceremonial, elected position of Kyiv mayor and the powerful position of head of Kyiv’s city-state administration, an appointment made by the Ukrainian president. The latter position gives him oversight of matters such as the city budget, building permits and transportation funds, making him one of the most powerful people in the country.

Mr. Klitschko supported Mr. Zelensky's opponent, the incumbent Petro O. Poroshenko, in last spring's presidential election in Ukraine. Mr. Zelensky's landslide victory appeared to augur Mr. Klitschko's political demise.

Mr. Zelensky, a comedian, had frequently lampooned Mr. Klitschko on his Saturday Night Live-style variety show, portraying him as a dunderheaded member of Ukraine's shadowy, corrupt elite. In one skit, Mr. Zelensky played a translator to a boxing-belt-wearing Mr. Klitschko, who is unable to string together an intelligible sentence.

After taking power in May, Mr. Zelensky had no way to remove Mr. Klitschko as mayor but could strip him of the more influential post as head of the Kyiv administration. Ukrainian politicians and analysts expected him to do so.

A confidante of Mr. Klitschko's, who spoke on condition of anonymity because he was concerned about harm to his business if he spoke publicly, said that by the end of July, "it was clear that only outside interference, say the president of the United States or anyone on his behalf," could save Mr. Klitschko from dismissal. As the power struggle escalated, Mr. Klitschko flew to New York to meet with Mr. Giuliani.

On July 30, in an apparent prelude to the dismissal, Mr. Zelensky’s chief of staff, Andriy Bohdan, called a news conference and accused Mr. Klitschko of allowing corruption to flourish in Kyiv. Without offering evidence, Mr. Bohdan said he had been offered a $20 million bribe for Mr. Klitschko to remain head of the Kyiv administration.

The next day, Mr. Klitschko posted photographs on Facebook of his meeting with Mr. Giuliani, his "old friend and one of the most authoritative mayors in the world." The two discussed "the situation in Ukraine," he said, "future cooperation between the United States and Ukraine," and the topic of "local self-rule" – an apparent reference to Mr. Klitschko's battle to hold on to power at home.

Read alsoKlitschko asks anti-graft watchdog to launch probe following President Office chief's "bribe offer" claim

Upon returning to Kyiv, Mr. Klitschko told his aides that his American allies would help him keep his job, according to several people who heard him make the comments in staff meetings and who spoke on condition of anonymity because they are still involved in municipal politics and were afraid to be identified when discussing issues related to Mr. Klitschko.

"That's ridiculous," Mr. Klitschko said in a statement on Friday. Asked about the meeting with Mr. Giuliani, Mr. Klitschko said, "I did not ask anyone for any assistance."

Mr. Klitschko said he had never had a business relationship with Mr. Giuliani, a claim contradicted by Mr. Giuliani, who consulted for the former boxer's 2008 campaign. Mr. Giuliani said that he had not formally represented Mr. Klitschko in years, "even though I still advise him."

But two days later, Mr. Giuliani was speaking about Mr. Klitschko to Mr. Yermak in Madrid.

On September 4, Mr. Zelensky’s cabinet approved the dismissal of Mr. Klitschko as head of the Kyiv administration.

But on September 6, Mr. Giuliani fired off a tweet: "Reducing the power of Mayor Klitschko of Kiev was a very bad sign particularly based on the advice of an aide to the President of Ukraine who has the reputation of being a fixer. The former champion is very much admired and respected in the US."

The tweet came as Mr. Zelensky was scrambling to stabilize his relationship with Mr. Trump after finding out that American military aid to Kyiv had been halted for unexplained reasons.

The last step needed to make the dismissal official was Mr. Zelensky's signature on the dismissal – a formality, it seemed, since it was Mr. Zelensky's office that had sought approval for the firing in the first place.

But the signature never came.

Asked by reporters in October, Mr. Zelensky said that he was still thinking about whether or not to sign.

"When a controversial issue arises, he tries to balance various interests," a Kyiv political analyst, Volodymyr Fesenko, said of Mr. Zelensky's unexpected reprieve. "He decided not to make a sudden move."

Aside from any influence Mr. Giuliani may have had, Mr. Fesenko points to a power struggle within different factions in Mr. Zelensky's administration as another factor, along with Mr. Zelensky's own dwindling political capital amid intense criticism from domestic political opponents that he was too soft on Russia.

Through a spokeswoman, Mr. Klitschko declined to comment on the Madrid meeting between Mr. Giuliani and Mr. Yermak, or on why Mr. Zelensky decided to keep him in office. He described Mr. Giuliani as "a big friend of Ukraine and one of the most successful mayors of the world."

Mr. Giuliani himself became a fraught figure in Ukraine as the impeachment investigation unfolded on Capitol Hill.

"Starting in late September, the Giuliani issue became very toxic," Mr. Fesenko said. "It seemed Klitschko's team stopped pushing the relationship with Giuliani."