Giuliani, who has said he had held a cybersecurity contract with Qatar in 2017 and early 2018, proposed replacing her with someone he said would be a better fit — Scott W. Taylor, a Trump-supporting former congressman from Virginia defeated in his reelection bid in November 2018, according to people familiar with his outreach.

Giuliani’s previously unreported attempts to shape the pick for the U.S. envoy to Qatar is part of an un­or­tho­dox foreign policy portfolio he has carved out for himself while also working as a power-broker-for-hire with direct access to the president and top administration officials.

The dual roles he has embraced is part of what longtime colleagues say has been a transformation of the once-iconic New York mayor into a multimillionaire consultant to powerful figures overseas.

In the three years since Trump took office, Giuliani has expanded his lucrative foreign consulting and legal practice, taking on clients that span the globe, from Turkey to Venezuela to Romania to Ukraine.

Along the way, he also has used his singular perch to try to influence U.S. policy and criminal investigations — at times pushing the interests of foreign figures who could benefit him financially.

Giuliani has said he separates his private business from the work he does for the president for free. He has said the kind of services he provides his foreign clients does not require registering with the U.S. government as a foreign lobbyist.

But since the start of the administration, his actions have caused persistent alarm among Trump’s advisers, who worry that it is often not clear who Giuliani is representing — the president, his private clients or his own foreign policy views — in his meetings at the White House and in foreign cities, according to people familiar with the concerns who spoke on the condition of anonymity to describe internal discussions.

Those worries have become acute since Giuliani emerged as a central figure in the Ukraine pressure campaign that is the subject of the House impeachment inquiry — and the arrests of two of his associates, Lev Parnas and Igor Fruman, who assisted him in that effort.

Federal prosecutors in New York are scrutinizing Giuliani’s business ties to the men and his consulting business as part of a broad probe, according to people familiar with the investigation.

In several conversations in recent months, Attorney General William P. Barr has counseled Trump in general terms that Giuliani has become a liability and a problem for the administration, according to multiple people familiar with the conversations. In one discussion, the attorney general warned the president that he was not being well-served by his lawyer, one person with knowledge of the episode said.

The Justice Department and the White House declined to comment. Giuliani did not respond to multiple calls and messages seeking his comment. His lawyer declined to comment.

Giuliani has assured the president that he is not in legal trouble, according to White House aides. And Trump has so far resisted entreaties to distance himself from the former New York mayor, telling others that he appreciates Giuliani’s combative media appearances on his behalf, according to White House officials and Trump advisers.

“He’s a good man and he’s an honorable guy and he’s a great crime fighter, corruption fighter,” the president said in an interview with Bill O’Reilly last month.

Last week, even as the House began drafting articles of impeachment, Giuliani kept up his work abroad on the president’s behalf, swooping into Kyiv to meet with Ukrainian prosecutors who he claims have damaging information about Democrats.

But the federal probe — being run out of the U.S. attorney’s office in Manhattan that Giuliani once led — appears to be delving into his foreign entanglements.

In recent weeks, prosecutors subpoenaed a consulting firm founded by former FBI director Louis Freeh, which hired Giuliani to write an August 2018 letter to Romanian officials calling for an amnesty for people prosecuted for corruption, a policy change that would have benefited a Freeh client, according to people familiar with the move. The subpoena has not been previously reported.

Freeh’s firm declined to comment, as did a spokesman for the U.S. attorney’s office in Manhattan.

This examination of Giuliani’s activities is based on interviews with more than 25 of his associates, current and former administration officials and other people familiar with his work, many of whom spoke on the condition of anonymity because of the ongoing criminal investigation.

In recent interviews, Giuliani told The Washington Post that questions about his foreign clients are “diversions by Democrats hoping to shoot the messenger” and an effort to distract from information he is uncovering about the president’s political opponents, such as former vice president Joe Biden.

“The Swamp Media is going back 20 years to find anything I could have done which they can paint as ‘wrong,’ ” he wrote in a tweet this fall.

Embracing a new lifestyle

Giuliani first came to prominence as the mob-fighting U.S. attorney in Manhattan in the 1980s, a position that helped propel him into the New York mayor’s office in 1994. His calm, take-charge leadership during the Sept. 11, 2001, terrorist attacks brought him international acclaim.

After leaving office, he parlayed that fame into a new role as a paid speaker around the world. The money that suddenly began flowing his way was a revelation, according to people who knew him.

One longtime friend recalled that during his travels for speeches abroad, Giuliani learned he could get paid $1 million or more as a consultant to foreign interests. He was stunned — and enticed, said the friend, who spoke on the condition of anonymity to describe private conversations.

Soon, Giuliani began living a much more affluent lifestyle, enjoying a house in the Hamptons, premium cigars, fine scotch, first-class travel and a luxury residence in New York. In 2003, he married his third wife, Judith Nathan, in an elaborate ceremony on the lawn of Gracie Mansion attended by 400 guests, including Trump. (The two are now in the midst of a bitter divorce.)

By the time Giuliani ran for president in 2008 — a bid that started strong but fizzled — his financial disclosure showed he had made $9.2 million for speeches alone between 2006 and mid-2007, many from domestic companies but also from foreign sponsors and think tanks. He made additional millions through his consulting company and his law firm, Bracewell & Giuliani, the disclosure showed.

But Giuliani’s failed presidential bid left the onetime hero “cast off into the political wilderness again,” said Andrew Kirtzman, a journalist who covered his political rise and wrote a 2001 biography of the former mayor.

He redoubled his efforts to make money, friends and associates noted.

“His values seemed to change,” Kirtzman said. “He was the least materialistic figure I’d ever covered back in his prosecutorial and mayoral days. His interest was always in power, not money. Then he became a man who was very interested in money.”

In the process, the former prosecutor began to drift away from colleagues he had known for decades, some of whom now express bewilderment at his transformation.

“There was a time when he wouldn’t take dirty money or questionable money or money of dubious origin,” said Ken Frydman, who served as the press secretary for Giuliani’s 1993 mayoral campaign, noting Giuliani was known then for vetting donors especially aggressively. “Today, it seems he’ll take money from anyone.”

Like Trump, Giuliani has always had a stubborn refusal to admit mistakes, Frydman said.

“Don’t back down. Don’t apologize,” Frydman said of Giuliani’s philosophy. But he said there is an “an intensity” to Giuliani now that goes beyond what he remembers: “He’s turned on the afterburners. He’s Rudy on steroids.”

Giuliani was soon moving in the same social circles as Trump, whom he had known for years in New York, emerging as one of the developer’s most vocal surrogates in the 2016 campaign.

After Trump’s surprise victory, Giuliani made clear he wanted to be named secretary of state, according to current and former administration officials. But a team of lawyers vetting potential administration appointees raised red flags about possible conflicts of interest arising from his work overseas, according to the officials.

A few weeks after Trump’s election, Giuliani announced that he had taken himself out of the running for the job. On Fox News, he said he planned to pursue his private legal and consulting business “with even more enthusiasm” than before Trump’s election.

Expanding foreign practice

The former New York mayor had robust work overseas before Trump took office. His companies, Giuliani Partners and Giuliani Security & Safety, provided security and emergency management consulting to governments in Peru, Chile, Argentina and Ukraine, among others. He gave paid speeches around the world, including to Mujahideen-e-Khalq, or MEK, an Iranian resistance group operating in exile that was listed as a terrorist group by the State Department as recently as 2012.

But Trump’s election provided Giuliani with a substantially bigger platform — and newfound access to the top levels of U.S. decision-making.

He became a mainstay at the Trump International Hotel down the street from the White House, where he has spent long evenings meeting friends and potential business partners. When he needs to privately discuss deals, he convenes meetings at some of his favorite cigar bars, including Shelly’s Back Room in Washington and New York’s Grand Havana Room, according to people familiar with the sessions.

Giuliani has bragged to other Trump allies that he has made millions of dollars since the president took office, according to people familiar with his comments.

He also has regularly boasted about his access to Trump and the closeness of their friendship, said a senior U.S. official who interacted with Giuliani.

In one meeting with a prominent Ukrainian political figure in early 2018, Giuliani was explicit that hiring him would provide a route to the president, according to a person in attendance.

“It was just so clear what he was peddling. He was pushing for business, and his pitch was, ‘I’m close to the White House, I’m close to Trump. If you want to get in there, I’m your guy,’ ” the person said. In that case, the Ukrainian did not hire Giuliani.

Giuliani used his access to Trump in 2017 to push for two controversial issues sought by Turkish President Recep Tayyip Erdogan, as The Post has previously reported.

Early that year, he was hired by the legal team of a Turkish-Iranian gold trader, Reza Zarrab, who was charged in New York with violating U.S. sanctions against Iran. The matter was of keen interest to Erdogan, who said Zarrab was a political “hostage” of American law enforcement. Giuliani met with the Turkish president on a visit to Istanbul in February 2017 to discuss a possible “state-to-state resolution in this case,” according to court filings in the Zarrab case.

In the fall of 2017, Giuliani attended an Oval Office meeting where Trump urged then-Secretary of State Rex Tillerson to consult with Giuliani and craft a diplomatic deal that would involve dropping charges against Giuliani’s client in exchange for concessions from Turkey, such as the release of an American pastor in Turkish custody.

People familiar with the incident have said Tillerson was shocked at what he viewed as an inappropriate request to intervene in a criminal matter. Tillerson has declined to comment.

Giuliani told The Post he sought a prisoner exchange but declined to comment on any private discussions on the topic. He said he did not need to register as a foreign agent for his Turkish advocacy because his only goal was to assist the legal case of his client, Zarrab. Defense attorneys are not required to register as foreign lobbyists when they assist clients in criminal or civil matters.

In late 2017, Zarrab pleaded guilty to orchestrating a multibillion-dollar conspiracy to evade U.S. sanctions against Iran by disguising money transfers so they would appear to be legitimate gold trades. He testified in federal court that the scheme was approved by Erdogan. Turkish officials denied any wrongdoing.

That year, Giuliani also persistently pushed Trump on another top concern of the Turkish president: extraditing exiled Turkish cleric Fethullah Gulen back to his home country to face prosecution. State Department and National Security Council officials have argued against such a move, but Trump appeared receptive to the idea, pressing his advisers about Gulen’s status, as The Post previously reported.

Giuliani declined to discuss whether he advocated for Gulen’s extradition, writing in a text message earlier this year: “can’t comment on it that would be complete attorney client privilege but sounds wacky.”

“I don’t represent foreign government in front of the U.S. government,” he told The Post earlier this year. “I’ve never registered to lobby.”

But inside the White House, officials were so disturbed by how he was promoting Turkey’s causes with Trump that then-Chief of Staff Reince Priebus pulled Giuliani aside in the West Wing in 2017 and warned him against lobbying for the country, officials said.

New proximity to president

In April 2018, Giuliani formally joined Trump’s legal team to help him deal with special counsel Robert S. Mueller III’s investigation, a position that required him to talk frequently with the president.

White House aides fear Giuliani has used his role as the president’s lawyer to promote the interests of private clients, fretting that they do not know who he represents, officials said. His conversations with Trump are protected by attorney-client privilege, meaning even Trump’s closest aides are not briefed on what they discuss.

Priebus’s successor, John F. Kelly, tried to limit Giuliani’s reach, scheduling his meetings with Trump at the White House residence, so he would not interact with other White House staff, former administration officials said. Kelly also told others he did not want to be part of calls or meetings with Giuliani, the people said.

Giuliani has insisted that he keeps his role as the president’s lawyer separate from the work he does for foreign interests.

“I’ve never lobbied him on anything,” Giuliani told The Post earlier this year, referring to Trump.

But he has continued to take on foreign clients, and, behind the scenes, his advocacy on foreign policy issues has not ceased, according to people familiar with his activities.

In the months after Giuliani joined Trump’s legal team, he began discussions with a group interested in influencing U.S. policy in Venezuela.

In the summer of 2018, over cigars and whiskey at New York’s Grand Havana Room, Giuliani met with Parnas and two American business executives with investments in the country seeking his advice on how to open a back channel of communication between Trump and Venezuela’s socialist leader, Nicolás Maduro, according to people familiar with the gathering.

As part of the previously unreported talks, Giuliani agreed to help find a way to negotiate with Maduro and a diplomatic solution to the political chaos and economic collapse overtaking the country, they said.

Weeks later, he told the group that he had met with John Bolton, the president’s national security adviser, to discuss the idea.

Charles Cooper, an attorney for Bolton, declined to comment.

Bolton’s distaste for Giuliani’s foreign policy freelancing has emerged during the impeachment inquiry. Former national security official Fiona Hill testified that Bolton warned her not to interact with the president’s lawyer, calling him “a hand grenade that is going to blow everybody up.”

After a contested election in January, Bolton urged Trump to formally recognize legislative leader Juan Guaidó as the country’s leader instead. Maduro has refused to abdicate and the United States imposed stiffer sanctions in response.

By this summer, Giuliani had picked up an important Venezuelan client: energy executive Alejandro Betancourt López, who hired Giuliani to help him contend with a Justice Department investigation of alleged money laundering and bribery, according to people familiar with the situation.

Giuliani stayed at Betancourt’s historic estate outside Madrid in August, when he met with a top aide to Ukrainian President Volodymyr Zelensky and urged him to open investigations into the 2016 election and Biden’s son Hunter’s work for a Ukrainian gas company , as The Post previously reported.

On Aug. 13, days after returning from Madrid, Giuliani was back at Grand Havana Room, meeting with another potential client: the National Bank of Ukraine, which had taken over a bank once owned by Ukrainian businessman Ihor Kolomoisky, according to a person familiar with the meeting.

He suggested that lawyers with the law firm Quinn Emanuel, which represents the Ukrainian state-owned bank, hire him to wage a public campaign against Kolomoisky, with whom the bank is engaged in a complicated legal battle. Kolomoisky is also considered a political supporter of Zelensky.

Giuliani told Bloomberg, which first reported the meeting, that he was approached by the lawyers for the bank to see whether he could help them with a civil suit. He said the timing was not right.

“Since representing Trump I have considered and turned down all deals in Ukraine, even those not presenting a conflict,” Giuliani tweeted last week.

A spokesman for Quinn Emanuel declined to comment.

Interest in Qatar

Giuliani’s interest in U.S. foreign policy has often tracked with countries where he has had a financial interest.

That was the case with his efforts to shape the pick for ambassador to Qatar, where he did security consulting work in 2017 and 2018 related to a hacking incident, Giuliani told The Post earlier this year.

He declined to describe the specific work he did but said his contract concluded before he was named Trump’s attorney in April 2018. He said that he did not register as a foreign lobbyist because he never lobbied U.S. officials on behalf of Qatar.

The Qatari Embassy in Washington declined to comment.

In November 2018, Trump nominated Mary Catherine Phee to fill the post of ambassador to Qatar, a key diplomatic job that had been vacant since June 2017. Phee had served as a career diplomat since 1991, including a stint as ambassador to Sudan.

She is known as “an old school, talented diplomat” whose “strong point is the nitty-gritty of bilateral relations,” according to a former senior administration official involved in Middle East policy.

Scott Taylor, who wrote a 2015 book called “Trust Betrayed: Barack Obama, Hillary Clinton, and the Selling Out of America’s National Security,” had experience in the region and with energy policy. He served as a security contractor for Hunt Oil in Yemen from 2008 to 2010, Taylor told the Virginian-Pilot before his 2016 election. While in Congress, Taylor worked to build ties with Qatar, visiting the country in 2017 and speaking at a Qatari event in Washington in 2018.

Giuliani offered to promote Taylor as candidate for the post and help guide him through the process, according to a person familiar with his outreach.

During a night at a cigar bar in Friendship Heights in December and a lunch meeting the following day at the Trump hotel, Giuliani described a plan to promote Taylor for the job, the person said.

During the conversations, Giuliani told Taylor that he had done work in Qatar, but it was unclear why he was interested in shaping the ambassador pick.

In subsequent calls to administration officials, Giuliani argued that Taylor would be a better choice than Phee because he would be more supportive of Trump’s agenda, according to multiple people familiar with the conversations.

As the process progressed, Giuliani also told Taylor he had discussed the idea with the president, who had seemed enthusiastic, one person said.

When asked about his advocacy for Taylor in a November interview, Giuliani laughed and ended the call.

Reached by phone, Taylor — who this summer launched a campaign to unseat Sen. Mark R. Warner (D) — declined to comment on Giuliani’s effort to get him the appointment, saying only, “I had a lot of advocates on that.”

The State Department declined to comment.

Phee’s nomination expired when Congress adjourned last year and Trump has not renominated her. He also did not name Taylor, leaving the key job vacant.

Foreign work under scrutiny

The scope of the ongoing investigation by federal prosecutors in Manhattan is unclear, but the recent subpoena to Freeh’s firm indicates that investigators appear to be drilling into Giuliani’s work abroad.

In August 2018, Giuliani sent a letter to the Romanian president, expressing his concern that “excesses” by the nation’s anti-corruption agency were resulting in the prosecution of innocent people. Giuliani called for an amnesty for people convicted under the system.

Giuliani told The Post at the time that he was hired to send the letter by Freeh’s firm. He declined to say on whose behalf Freeh’s firm was working or how much he was paid.

But Freeh has said he was hired in July 2016 to conduct a review of the conviction of Gabriel “Puiu” Popoviciu, a Romanian real estate executive sentenced to seven years in prison for fraud.

Popoviciu originally hired Freeh at the recommendation of Hunter Biden, who had been retained by the Romanian, an attorney for the former vice president’s son, George R. Mesires, confirmed. The New York Times first reported Hunter Biden’s role. A Biden campaign official said Hunter Biden never discussed his Romania work with his father, who actively supported anti-corruption initiatives in the country.

Giuliani’s letter to the Romanian president, written on the letterhead of his firm Giuliani Partners, did not mention his relationship to Trump. But it caused an immediate stir in Bucharest, where news organizations highlighted Giuliani’s role as the president’s attorney and questioned whether the letter indicated a shift in U.S. support for the anti-corruption agency.

The State Department tried to distance itself from him. “Rudy Giuliani does not speak for the U.S. government on foreign policy,” an official told The Post at the time.

Giuliani has repeatedly dismissed questions about the propriety of his foreign work.

“5 different organizations are looking at 8 different cases trying to find something wrong. why if I’m not part of a Left Wung [sic] Witchunt for nailing Biden,” he wrote in a recent text message.

But people familiar with the current investigation have said federal prosecutors are exploring a wide range of potential crimes — including wire fraud and failure to register as a foreign agent — as they examine Giuliani’s relationship with his two associates, Parnas and Fruman.

The two men were charged in October with campaign finance violations. The allegations do not implicate Giuliani and both have pleaded not guilty.

Parnas and Fruman were key intermediaries who helped connect Giuliani early this year with Ukrainian officials such as Ukraine’s then-top prosecutor, Yuri Lutsenko, who was offering damaging information about Trump’s political opponents, Giuliani and Parnas have said.

Giuliani’s efforts in Ukraine soon merged with official U.S. policy. He pushed White House and State Department officials to issue a visa to a former Ukrainian prosecutor who was blocked from traveling to the United States because of corruption allegations, according to testimony from U.S. officials during the impeachment hearings.

And he lobbied Secretary of State Mike Pompeo to dismiss the U.S. ambassador, speaking with Pompeo twice by phone and then sending him a packet of material advocating her removal, documents show.

Yovanovitch was removed from her post in May, the same month Trump directed top U.S. officials working on Ukraine policy to coordinate with his private attorney. By July, Trump was personally involved in the effort, pressing Zelensky by phone to work with Giuliani to open the investigations.

Giuliani has insisted he was not paid for the work he did for Trump. But he has acknowledged that in January he considered representing Lutsenko and the Ukrainian Ministry of Justice, writing a draft contract to formalize the deal in which he would have been paid $500,000.

He told the Wall Street Journal that he quickly decided against the arrangement, fearing it could pose a conflict with his representation of the president.

Last week, Giuliani traveled to Budapest, where he met with Lutsenko, then traveled to Kyiv, where he met with two members of Ukraine’s parliament who have called for a joint U.S.-Ukrainian parliamentary investigation into the gas company that hired Hunter Biden.

During the trip, Giuliani indicated he was speaking for the United States, writing on Twitter that until Ukraine investigates the “criminal conduct” of Biden, it “will be a major obstacle to the U.S. assisting Ukraine with its anti-corruption efforts.”

The president appeared pleased with his efforts, telling reporters Saturday that Giuliani was going to “make a report” to the attorney general and Congress.

“He says he has a lot of good information,” Trump said, adding: “I hear he has found plenty.

Anne Gearan, Alice Crites and John Hudson contributed to this report.