WASHINGTON — Special counsel Robert Mueller knew President Trump had to beat him up publicly and notified the White House “in code” about erroneous press reports about his investigation, Trump’s former lawyer said.

“Bob was a big boy about the political side,” Trump’s ex-attorney John Dowd said in a podcast interview with the Washington Examiner. “He understood the president had to address the politics of it. He couldn’t just say nothing because people … were pounding him about this thing every day, both privately and publicly, so he had to take it on and his view was that it was a nothing. It was a waste of time and a waste of money.”

For months, while Mueller’s team was scrutinizing the Russian connections to the president’s 2016 campaign, Trump was calling the investigation a hoax and a witch hunt.

Behind the scenes, however, things were more amicable, Dowd said.

“Early on, when the president started teeing off on Mueller, Mueller indicated to me that he was worried that some people might not cooperate, and I said, ‘Well, we’ve encouraged everyone to cooperate and if you want me to say something publicly about that, and the president, we’re happy to do it.’ And we did,” Dowd said, adding that the conversation happened during the summer of 2017.

Mueller was appointed by Deputy Attorney General Rod Rosenstein in the days after Trump fired FBI Director James Comey. Trump’s original attorney general, Jeff Sessions, had already recused himself from all things Russia-related because he had a role on the president’s campaign.

Dowd said Rosenstein thought he was going to get axed over his decision to appoint Mueller. He never was and remains at the Department of Justice under new Attorney General William Barr.

Sessions apparently was embarrassed by Mueller’s appointment without his knowledge and offered to resign — an offer that was rejected at the time.

Dowd also said Trump never had any plans to fire Mueller while the special counsel was investigating the president.

“All this, what I call mainstream knee-jerk theories, these wild theories that he was really trying to get rid of Bob, that was nonsense,” Trump’s former lawyer said.

In reality, Dowd said, there was great trust between the two teams.

“It was an extraordinarily trusting relationship, we relied on each other’s words and as I say, the only disappointment I have is this thing took too damn long,” Dowd said.

He said Mueller’s lawyers would call Trump’s team and ask for documents and they would send them over.

“In fact, in the March 5 meeting of 2018, [Mueller] acknowledged that all the witnesses told the truth, all the documents were there … nothing was missing, no documents destroyed and it was truly remarkable, yet the mainstream media and other people don’t want to give him credit for it,” Dowd said.

The lawyer also said there was a back channel between the special counsel’s office and his team when media reports were off base, such as a Bloomberg story saying Mueller was investigating Trump’s business dealings.

Since the special counsel’s office rarely made public statements, Dowd said he would meet with Mueller’s deputy James Quarles, who would signal to him when something wasn’t right in the press.

“So I had to go by this office to drop something off, and we met outside. And he said, in code, don’t believe everything you read in the papers. I said, ‘I got it, OK,’ and then I could say [to Trump], ‘I talked to the special counsel and there was no basis for it,’” Dowd said.