Last week, President Donald Trump weighed into a contentious House Republican primary battle, officially endorsing the establishment incumbent over a pugnacious challenger with Trumpian appeal.

Among those encouraging the president to throw his weight behind Rep. Dan Donovan (R-N.Y.) was his newest attorney, Rudy Giuliani, who himself endorsed Donovan’s reelection bid against his primary challenger, former congressman and convicted felon Michael Grimm.

“I like both of them,” Giuliani told The Daily Beast, referring to Donovan and Grimm, “but I thought, as did several other people that spoke to the president, that Donovan has a better chance of winning."

Trump’s decision to heed Giuliani’s advice and officially endorse Donovan last Wednesday highlights the expanded influence that the former New York City mayor is exerting within the White House orbit. Giuliani has become not just a lead attorney on Trump’s legal team but also a political adviser, a prominent media surrogate, and even an apparent foreign policy spokesman—sometimes to the chagrin of senior administration officials.

“Just because I’m acting as his lawyer does not mean we don’t talk about other things,” said Giuliani. "I’m one of his closest friends, I've given him political advice for years.”

Giuliani has, indeed, been a long time adviser of Trump’s including the heydays of the 2016 election. But only recently has he had such a direct audience with the president. And he’s proving willing to use his access.

The former mayor pleaded Donovan’s case at a small meeting last month, shortly after Trump attended a Long Island event with Donovan and Rep. Peter King (R-N.Y.), where the president doubled down on his controversial characterization of MS-13 gang members as “animals.”

Giuliani said the meeting at which he advised Trump to back Donovan also included “at least three [other] people…giving [Trump] advice of a similar nature” and that it lasted for roughly fifteen minutes. He would not say who else was present, though he noted that King had previously suggested to Trump that he talk to Giuliani about a potential Donovan endorsement. Giuliani had endorsed Grimm during his initial congressional run in 2010, but said he agreed that Grimm’s criminal record would make him less electable this November.

Trump’s endorsement of Donovan came less than a month ahead of his primary contest against Grimm, who held the seat before going to prison in 2015 on federal tax evasion charges. Both candidates sought Trump’s endorsement, which carries significant political weight in the Staten Island district.

“We expected that from the former mayor of NYC. No surprise,” said Michael Caputo, a former Trump campaign adviser who now works on Grimm’s campaign, of Giuliani’s role in steering the president in Donovan’s direction. “The flawed calculus behind the move has been circulating from the RNC to the NRCC to the White House political shop for weeks.”

Choosing which House races are worthy of presidential engagement is the sort of advice that would normally come from White House political advisers. But for Giuliani, it’s the latest addition to a portfolio expanding far beyond matters pertaining to the federal investigation into Russian meddling in the 2016 presidential election.

Trump hired Giuliani to helm his personal legal team in April, and by the following month the ex-mayor quickly became ubiquitous on TV news, in the process becoming a public face on a litany of matters, many unrelated to the Russia investigation.

Giuliani announced the North Korean government’s release of three American prisoners days before the White House confirmed the news. That prompted the State Department to distance itself from Giuliani, with department spokeswoman Heather Nauert stating, “he speaks for himself and not on behalf of the administration on foreign policy.”

Even on legal matters, Giuliani has publicly strayed from the federal investigation he was brought on board to handle. In his first major TV appearance as a member of Trump’s legal team, Giuliani weighed in on payments from Michael Cohen, the president’s longtime fixer and attorney, to porn star Stormy Daniels in exchange for an agreement late in the 2016 campaign to stay quiet about an alleged affair with Trump. Giuliani’s comments during that Fox News interview with host Sean Hannity blindsided senior West Wing officials.

When Giuliani has stayed within his formal purview, he has often operated in a role more traditionally suited for a spokesman than a legal counselor. Over the weekend, he told ABC’s This Week that President Trump “probably” has the constitutional authority to pardon himself though he had “no intention” of doing so.

“The president would be committing political suicide pardoning himself,” he told The Daily Beast, elaborating on those comments. “The practical control on that would be that Congress would impeach him… No way in the world that President Trump is going to do that…He did nothing wrong.”

Giuliani’s comments on ABC set off a firestorm in Washington on Monday. But by the next day, he was already halfway around the world. He spoke with The Daily Beast over the phone from Israel, where he is scheduled to speak at the Globes Capital Markets Conference on Wednesday. He said he was talking on issues of cyber security, and that he committed to speak at the conference “months ago.” Later that evening, he was doing another television interview, this time on CNN.

The totality of Giuliani’s comments, and his aggressive PR streak, has led former Bill Clinton legal hand Lanny Davis to conclude that the president’s legal strategy is inextricably linked with his political concerns. Davis, who served a similar role to Giuliani’s in the Clinton White House, speculated that what Giuliani was trying to do was to spark an electorally-advantageous debate over impeachment by making broad claims about the president’s legal powers.

Republicans, Davis said, “want impeachment to be on the ballot in 2018.” As long as Republicans continue to support the president, “there will never be a bipartisan two-thirds vote [for impeachment] in the Senate. Ergo, everything that Giuliani is doing makes sense if it’s simply, ‘bring it on, try to impeach me.’”