As 2018 came to a close, the special counsel investigation was bearing down on President Trump.

Special counsel Robert S. Mueller III had secured the cooperation of Trump’s onetime fixer, Michael Cohen, and appeared to be preparing to indict a longtime adviser, Roger Stone. Trump’s former campaign chairman, Paul Manafort, was in jail after pleading guilty to multiple felonies, and Mueller’s prosecutors were pressing him to explain why he had given 2016 polling data to an associate with alleged ties to Russian intelligence.

It was in this uncertain moment that Trump’s personal attorney Rudolph W. Giuliani said he had the idea to focus on Ukraine. That November, he received a tip from a former colleague that it was the Ukrainians who had conspired to help Democrats in 2016, Giuliani said in recent interviews.

“I knew they were hot and heavy on this Russian collusion thing, even though I knew 100 percent that it was false,” Giuliani recently told conservative broadcaster Glenn Beck. “I said to myself, ‘Hallelujah.’ I’ve got what a defense lawyer always wants: I can go prove someone else committed this crime.”

Giuliani’s efforts to undermine the special counsel probe eventually snowballed into the current impeachment crisis gripping the capital — highlighting how the pressure Trump and his allies put on Ukraine originated as an effort to sow doubts about the Russia investigation.

“All roads lead to Russia,” said Paul Rosenzweig, who served as a lawyer on then-independent counsel Kenneth Starr’s team in the 1990s, noting that the theories about Ukraine have been described by former U.S. officials as Russian propaganda.

The direct connection between the Mueller investigation and the Ukraine pressure campaign, often lost as the administration has reeled from controversy to controversy, shows the deep imprint the Russia investigation has had on the president.

Ultimately, Mueller would find that Russia’s efforts to interfere in the 2016 campaign were “sweeping and systematic,” but that the evidence did not establish that the Trump campaign conspired with Russia.

Still, Trump’s determination to undercut the special counsel’s findings was so great that, the very day after Mueller testified before Congress, the president appeared to solicit another country’s political help in a phone call to his Ukrainian counterpart.

In his July 25 call with Ukrainian President Volodymyr Zelensky, Trump described the Mueller investigation as “nonsense,” emphasizing that it was very important to get to the bottom of what really happened.

“They say a lot of it started with Ukraine,” Trump said in the call, which sparked the original whistleblower complaint.

The echoes of the Russia investigation can also be seen in how Trump has responded to the Ukraine scandal. As he did with the Mueller probe, the president has sought to undermine the investigation’s legitimacy, refused to cooperate fully and publicly attacked witnesses.

Democrats are now weighing whether to include Trump’s conduct during both investigations in articles of impeachment that will be considered by the House this month.

“What Trump learned was always punch back. Demonize everyone. Fight to the last drop. Do what you want — it’ll work out in the end,” Rosenzweig said.

Indeed, the president’s latest message has been resonating: In recent weeks, his allies have increasingly been touting Ukraine’s alleged involvement in 2016.

“I think both Russia and Ukraine meddled in the 2016 election,” Sen. John Neely Kennedy (R-La.) said on NBC’s “Meet the Press” on Sunday. Intelligence officials have concluded that it was Russia that interfered in the campaign.

On Monday, Sen. Richard Burr (N.C.), the GOP chairman of the Senate Intelligence Committee, told NBC: “Every elected official in the Ukraine was for Hillary Clinton. Is that very different than the Russians being for Donald Trump?”

An early focus on Ukraine

Giuliani has repeatedly said the public does not appreciate the extent to which his work in Ukraine was driven by the Mueller investigation, rather than — as Democrats have alleged — as an effort to bolster Trump’s reelection in 2020.

While the impeachment inquiry has focused largely on the effort by Trump and his allies to seek damaging information about former vice president Joe Biden, Giuliani has noted that his Ukraine research began in late 2018, several months before Biden announced his presidential bid.

“The investigation I conducted concerning 2016 Ukrainian collusion and corruption, was done solely as a defense attorney to defend my client against false charges, that kept changing as one after another were disproved,” Giuliani tweeted last month.

The Ukraine theory had been floated early on by Manafort, recently released internal documents from Mueller’s investigation show.

In the summer of 2016, as Manafort faced building questions about lucrative lobbying work he did in Ukraine, he began to suggest to other Trump campaign aides that the Ukrainians might have been responsible for hacking the Democratic National Committee in 2016, rather than the Russians, according to what his deputy, Rick Gates, told the FBI.

Gates told investigators that Manafort’s comments attributing the hacks to Ukrainians “parroted a narrative” that was also advanced at the time by Konstantin Kilimnik, an employee of Manafort whom the FBI has assessed to have ties to Russian intelligence. (Kilimnik denies such ties.)

As the special counsel investigation got underway in 2017, other Trump allies began promoting the alternative Ukraine theory.

In a text conversation with Manafort from August 2017 released by prosecutors, Fox News host Sean Hannity cited “Ukraine interference” as one of the issues he was highlighting to attack ­Mueller.

By early 2019, Giuliani began meeting with Ukrainian prosecutors. At the time, he and other Trump lawyers were bracing for the release of Mueller’s report and particularly what it would say about Manafort, who prosecutors said had breached his plea agreement by lying about key details of the 2016 campaign.

Notes from Giuliani’s meetings, which were turned over to impeachment investigators, show he appeared to be gathering information that could help him argue that Manafort was set up when damaging information about his work as a political consultant in Ukraine had been published in 2016, forcing his ouster as Trump’s campaign chief.

During this time, Giuliani has said, he consulted with Manafort — who was by then incarcerated — through his lawyer.

Giuliani was focused on the theory that the Ukrainian government interfered in the 2016 campaign through the activities of a Ukrainian American contract worker for the DNC, Alexandra Chalupa, which she has denied. This year, he met with a low-level Ukrainian diplomat who has alleged that officials at Ukraine’s embassy were feeding information about Manafort to Chalupa.

“I believed there was a lot of evidence that the [Democratic National Committee] and the Clinton campaign had a close connection to Ukrainian officials,” Giuliani told The Washington Post in October.

Giuliani said his consultation with Manafort also centered on trying to ascertain the veracity of a secret black ledger obtained by Ukraine’s National Anti-Corruption Bureau, which the New York Times revealed in an August 2016 article. The Times said the ledger recorded $12.7 million in cash payments from then-President Viktor Yanukovych’s political party to Manafort.

Giuliani suggested it was leaked by Ukrainians to hurt Trump — ignoring the widespread anger in Ukraine about the role Manafort played in helping elect Yanukovych, who was allied with Russia and fled to Moscow in 2014.

Manafort ultimately pleaded guilty to illegally routing $60 million in payments from his Ukraine clients through a series of offshore bank accounts and failing to pay taxes on about half the funds.

Serhiy Leshchenko, the Ukrainian journalist and former lawmaker who helped publicize the secret payments, has said he was motivated solely by a desire to hold Manafort and Yanukovych accountable.

“Giuliani’s entire approach is built on disinformation and the manipulation of facts,” he wrote in an op-ed in The Post in September. He has denied allegations from Republicans that he provided the document to the Times.

Legal experts said Giuliani’s theories appeared to be aimed primarily at shaping public perception.

“It strikes me as less of a legal strategy than a public relations campaign to distract attention from the core operative facts,” said David Laufman, a former senior Justice Department official who was involved with the early stages of the Russia investigation. “It is true that Mr. Giuliani is a lawyer. It does not mean that every endeavor he engages in involves providing legal services, rather than other types of services.”

However, Giuliani’s ideas strongly resonated with Trump, who has personally embraced the idea that Ukraine was the real culprit in 2016.

“They tried to take me down,” he told advisers in May, as The Post previously reported.

The president has even touted a debunked conspiracy theory that cybersecurity firm CrowdStrike, which analyzed the DNC hacks, spirited the party’s server that was hacked to Ukraine.

“I would like you to find out what happened with this whole situation with Ukraine, they say CrowdStrike. . . . I guess you have one of your wealthy people. . . . The server, they say Ukraine has it,” Trump told Zelensky. “There are a lot of things that went on, the whole situation.”

Trump told Zelensky he wanted to have Attorney General William P. Barr call Zelensky or his people and “get to the bottom of it.”

Former national security officials have expressed alarm at the traction of Giuliani’s theories on Ukraine, particularly the allegation about CrowdStrike.

“I am deeply frustrated with what he and the legal team is doing and repeating that debunked theory to the president,” former homeland security adviser Tom Bossert said of Giuliani on ABC’s “This Week” in September. “It sticks in his mind when he hears it over and over again, and for clarity here . . . let me just again repeat that it has no validity.”

Former National Security Council official Fiona Hill testified last month that any action by Ukrainians to influence the 2016 vote in the United States was the work of individuals expressing policy views — rather than a ­government-led campaign of illegal acts like the one conducted by Russia.

“This is a fictional narrative that has been perpetrated and propagated by the Russian security services themselves,” Hill said of the allegation that Ukraine also interfered in the election. “The unfortunate truth is that Russia was the foreign power that systematically attacked our democratic institutions in 2016.”

Reprising tactics

Trump now appears to be applying the lessons of the special counsel experience to the congressional impeachment inquiry.

In the first probe, the president refused to be interviewed by prosecutors, but the White House did permit staff members to talk to investigators and turned over 20,000 pages of documents, exposing damaging information about Trump’s efforts to block the probe.

Most of the Mueller report’s second volume, which catalogues how Trump worked to undermine the investigation into his campaign, was built on the accounts of Trump’s own aides.

Still, Trump’s refusal to sit for an interview proved effective. Although the special counsel found that many of the written answers submitted by his lawyers as a substitute for an interview were “imprecise” or “inadequate,” Mueller chose not to issue a subpoena for his testimony, anticipating that it would lead to lengthy litigation.

The special counsel ultimately decided not to come to a conclusion as to whether Trump had broken the law by obstructing the probe. But, Mueller wrote, “while this report does not conclude that the President committed a crime, it also does not exonerate him.”

This time around, Trump’s lawyers have decreed that there should be no cooperation with Congress at all. The White House has not turned over any documents to lawmakers and has directed key aides not to testify, including acting chief of staff Mick Mulvaney and former national security adviser John Bolton.

Democrats in Congress now face the same difficult choice as Mueller — whether to allow their investigation to get bogged down by lengthy court battles to force cooperation or to push forward without additional evidence.

In another way, the president is reprising tactics he used in the special counsel probe, when he repeatedly attacked witnesses, comments Mueller said appeared intended to impede cooperation.

In recent weeks, Trump has heaped public scorn on officials who have chosen to testify before Congress, targeting former ambassador to Ukraine Marie Yovanovitch, national security official Lt. Col. Alexander Vindman and an aide to Vice President Pence who testified last month.

“It’s very intimidating,” Yovanovitch told members of Congress of Trump’s public attacks. “I can’t speak to what the president is trying to do, but I think the effect is to be intimidating.”

And, as he did with the Mueller investigation, the president has kept up a nonstop series of attacks on the inquiry.

“The Republican Party has NEVER been so united!” he wrote on Twitter on Monday. “This Impeachment Scam is just a continuation of the 3 year Witch Hunt, but it is only bringing us even closer together!”