Three ominous words uttered in the Oval Office led two American diplomats on a journey that ended in a Capitol basement room as key witnesses in the House impeachment inquiry: “Talk to Rudy.”

President Trump’s instruction in May to a U.S. delegation that had just returned from Ukraine made clear that his personal attorney Rudolph W. Giuliani was playing the driving role in shaping the president’s view of that country — and that top officials needed to cater to him, according to transcripts of testimony released this week.

“Rudy had some bad issues with Ukraine, and until Rudy was satisfied, the president wasn’t going to change his mind,” European Union Ambassador Gordon Sondland said in his testimony to House investigators.

After the May 23 Oval Office meeting, Kurt Volker, then-special envoy to Ukraine, contacted Giuliani, attempting to court his support for U.S. foreign policy goals, and also put him in touch with a top Ukrainian official. At one point, he and Sondland even conferred with Giuliani on the language of a public statement that the new Ukrainian president was considering making, text messages show.

In a sign of his disproportionate influence, Giuliani was cited by name 480 times during Sondland’s and Volker’s depositions — more than any Trump White House or Cabinet official. The lawyer was repeatedly described as inexplicably powerful and difficult to control.

“He was always swirling around somewhere,” Sondland said of Giuliani, adding that he did not believe anyone wanted to deal with the former New York mayor.

Giuliani did not respond to a request for comment. He has previously said he was working on behalf of the president and in conjunction with the State Department, and that he kept Volker and Sondland apprised of his interactions with Ukrainians.

But the testimony and documents that have emerged in the ongoing impeachment inquiry underscore how much Giuliani — someone without a government portfolio — was driving official U.S. policy.

In his July 25 call with Ukrainian President Volodymyr Zelensky, Trump told the newly elected leader to deal with his personal attorney.

“I will have Mr. Giuliani give you a call,” Trump said, according to a rough transcript released by the White House.

Meanwhile, the top diplomats were scrambling to figure out how to handle Giuliani, someone they viewed as poisoning the president’s view of Ukraine.

From the early days of his tenure, Volker said, Trump told the pair that Giuliani had told him the Ukrainians are “all corrupt, they’re all terrible people, that they were — they tried to take me down — meaning the president in the 2016 election.”

Sondland said he believed the State Department should be in charge of foreign policy, but officials were powerless to thwart the former mayor, according to his testimony.

“It’s something we have to deal with,” Secretary of State Mike Pompeo said of Giuliani, rolling his eyes, according to Sondland’s testimony.

After Zelensky was elected, Sondland, Volker, Energy Secretary Rick Perry and Sen. Ron Johnson (R-Wis.) went to the Oval Office to brief Trump on a trip they had taken to Ukraine and to push for a meeting between the two leaders. They were excited about the new government, according to the testimony.

But Trump was uninterested, Sondland said, “going on and on and on about his dissatisfaction with Ukraine. He didn’t even want to deal with it anymore.”

“And he basically said, go talk to Rudy, he knows all about Ukraine,” Sondland said, recounting that the Oval Office meeting was cut short. Giuliani was not present.

Sondland said the group was “disappointed” but felt they faced an impossible choice: either abandon the goal of a meeting between Trump and Zelensky, or deal with Giuliani.

Volker voiced that resignation a few days later in a text to a longtime State Department colleague, William B. Taylor Jr., who was considering returning to Kyiv as ambassador: “I don’t know if there is much to do about the Giuliani thing.”

Taylor later told House investigators that he believed Giuliani led Volker astray.

“When he got involved with Mr. Giuliani, I think that that pulled him away from, or it diverted him from, being focused on what I thought needed to be focused on,” Taylor told lawmakers, according to a transcript released Wednesday. “The Giuliani factor, I think, affected Ambassador Volker.”

After the Oval Office meeting, Volker set up a channel to Giuliani, texting him on the morning of July 10 asking him to “meet for coffee or lunch in the next week or so.”

In a series of texts over the summer, the veteran diplomat sought to gently lobby and cajole the president’s lawyer.

According to his testimony, Volker tried to warn Giuliani that a former Ukrainian prosecutor general with whom Giuliani met on several occasions was “not credible.” He also “pushed back” on Giuliani’s fixation with former vice president Joe Biden and his son Hunter’s role as a board member of a Ukrainian gas company, telling him at a breakfast meeting on July 19 that “it is simply not credible to me that Joe Biden would be influenced in his duties as vice president by money or things for his son or anything like that.”

He also warned the Ukrainians that Giuliani was shaping the president’s negative views of their country, a message that prompted Andrey Yermak, a top aide to Zelensky, to request a meeting with Giuliani.

The Ukrainians believed, Volker said, that if they spoke to Giuliani, the “information flow would reach the president.”

Volker reported back to Giuliani with good news. He told Trump’s personal attorney that he had an “opportunity to get you what you need” on the subject of Ukraine, according to text messages released Tuesday. He then helped set up a meeting between Giuliani and Yermak.

That sit-down in Madrid three weeks later created a new set of problems, Volker testified, adding that he believes that is when the idea was hatched for the Ukrainians to put out a statement vowing to open the corruption investigations that Trump was seeking.

A week before, Trump had asked Zelensky to investigate Hunter Biden and whether Ukraine interfered in the 2016 election, the transcript of their call shows.

After the Madrid meeting, Yermak sent Volker a draft statement that referred to “the problem of interference in the political processes of the United States,” text messages show.

Volker and Sondland consulted with Giuliani on the statement. The president’s lawyer did not find it “convincing,” Volker recalled.

“Mr. Giuliani was the one giving the input as to what the president wanted in the statement. He wanted Burisma and 2016 election mentioned in the statement. And I don’t believe the Ukrainians were prepared to do that,” Sondland said.

Sondland said he was worried.

“What I was concerned about was that Zelensky would say whatever he would say on live television and it still wouldn’t be good enough for Rudy/the president, and then we would be having to go back and tell Zelensky, sorry, not good enough, and that would be extremely embarrassing,” Sondland said.

Sondland suggested the Ukrainians provide a summary of what they planned to say to the Americans “so that it can be run by Mayor Giuliani first to nail down what it is exactly that the president was asking or Giuliani was asking versus what Zelensky was intending to say. I didn’t want there to be a false press statement made live that was inadequate in some way.”

In a group text with Sondland, Volker sent back new language to Yermak that included “2 key items” — specific references to Burisma, the company on whose board Hunter Biden served, as well as the 2016 election.

But privately, Volker said he warned Yermak that releasing the statement “was not a good idea” and could entangle the Ukrainians in U.S. domestic politics.

“Because of conversations with Giuliani, I wanted to make sure that I was cautioning the Ukrainians, ‘Don’t get sucked in,’ ” Volker recounted.

Later, Volker said, when the Ukraine scandal broke into public view, Giuliani sought to get him to put out a misleading statement about the role he had played.

In a Sept. 22 text message to Volker, Giuliani urged him to “tell the truth” that he had “reported back to you and Sondland” about his interactions with the Ukrainians.

But Volker refused to comply with Giuliani’s request because it was “not the truth” that the president’s lawyer was acting at the direction of the State Department, he told lawmakers.

“I wasn’t giving any direction to him in any way,” Volker said.

Andrew Ba Tran, Mike DeBonis, Karoun Demirjian, Greg Jaffe, Elise Viebeck and Aaron C. Davis contributed to this report.