Sen. John McCain spoke out Saturday in defense of the free press after President Trump lashed out against the news media several times over the past week, at one point declaring it “the enemy of the American People!

Such talk, McCain (R-Ariz.) said on NBC News in an interview set to air Sunday, was “how dictators get started.”

“In other words, a consolidation of power,” McCain told “Meet the Press” host Chuck Todd from Munich. “When you look at history, the first thing that dictators do is shut down the press. And I'm not saying that President Trump is trying to be a dictator. I'm just saying we need to learn the lessons of history.”

The 80-year-old Republican senator was responding to several tweets by Trump over the past week, in which he repeatedly attacked the media as “fake news.” In one widely shared tweet Friday, Trump said the press was “not my enemy” but that of the American people.

In it, Trump tagged the New York Times, CNN and broadcast news networks NBC, ABC and CBS.

In the backlash to the tweet, #NotTheEnemy began trending, with people sharing stories about journalists who had dedicated their lives to — and, in some instances, paid the ultimate price for — reporting the news.

In the “Meet the Press” interview, McCain told Todd that a free press was central to a functional democracy, even if news organizations' stories challenged those being held accountable.

“I hate the press. I hate you, especially,” he said to Todd, who laughed. “But the fact is, we need you. We need a free press. We must have it. It's vital.”

“If you want to preserve democracy as we know it, you have to have a free and, many times, adversarial press,” McCain added. “And without it, I am afraid that we would lose so much of our individual liberties over time. That's how dictators get started.”

These days, it is difficult not to notice McCain, whose dissenting voice can be heard — and is often amplified — criticizing Trump. In the four weeks since Trump's inauguration, McCain has made headlines rebutting White House press secretary Sean Spicer and ripping Trump's worldview in a speech in Munich without ever mentioning the president's name.

Sen. John McCain (R-Ariz.) hit out at President Trump in a speech on Feb. 17 at the Munich Security Conference, saying, "this administration is in disarray." (Reuters)

Even before the inauguration, McCain was emerging as one of the few Republicans who was not afraid to criticize Trump, blasting the president-elect's reported consideration of reinstating waterboarding as an interrogation technique.

“I don’t give a damn what the president of the United States wants to do or anybody else wants to do. We will not waterboard. We will not torture,” McCain said to applause at a November summit, emphasizing certain words with a point of his finger. “My God, what does it say about America if we're going to inflict torture on people?”

McCain's repeated criticisms of Trump have triggered the president's wrath, most recently after McCain questioned the success of a deadly military raid in Yemen.

This week, McCain appears on the cover of the Feb. 20 issue of New York magazine, where he candidly discusses operating in the Trump administration in a nearly 5,000-word profile by Gabriel Sherman, the magazine's national affairs editor.

In one particularly strongly worded exchange, McCain does not hold back on how he views the severity of alleged Russian interference in the American presidential election.

“The severity of this issue, the gravity of it, is so consequential because if you succeed in corrupting an election, then you’ve destroyed the foundation of democracy,” McCain told Sherman. “So I view it with the utmost seriousness. I view it more seriously than a physical attack. I view it more seriously than Orlando or San Bernardino. As tragic as that was, the far-reaching consequences of an election hack are certainly far in excess of a single terrorist attack.”

Russian President Vladimir Putin, he said later, would not stop “until the cost of going forward is too high." (As for why his Republican colleagues were not more vocal about demanding investigations of Trump's Russian connections, McCain told Sherman pithily: “I frankly don't know. It's not a chapter of 'Profiles in Courage.'")

In the wide-ranging profile, which covers everything from Supreme Court justice nominee Neil Gorsuch to Trump's poll numbers, McCain also defends the news media in relation to leaks that have come from the Trump administration.

“In democracies, information should be provided to the American people,” McCain told Sherman. “How else are the American people going to be informed?”

The dramatic headline on the cover of the magazine — “McCain vs. Trump: Just how far will the senator go?" — is in many ways an oversimplification of their relationship, a facile understanding McCain himself pushes against throughout Sherman's piece. At one point, McCain dismisses the idea that he could be swayed by Democrats seeking to protest Trump's agenda.

“These are the same Democrats that shredded me in 2008,” McCain told Sherman. “I get along with the Democrats, but please, I’m not their hero. They’re trying to use us. We will work with them, but have no doubt, their agenda is not our agenda.”

And McCain's criticisms of Trump could hurt Democrats in other ways, The Post's Dave Weigel notes in his analysis of the latest crop of McCain-centered headlines:

Pushed by their party's base, Senate Democrats have been moved from generally supporting Trump nominees to mostly opposing them. . . . But right now, progressives view the Democratic Party warily. They can ill afford a story line in which Republicans such as McCain (or Evan McMullin, or Joe Scarborough) are the real leaders of the opposition.

Still, McCain told Sherman he was not concerned about Trump's administration becoming an “authoritarian regime.”

“I just don’t think it’s possible in our society,” he said in the profile. “There’s too many checks and balances. The danger is not Trump perverting our Constitution or taking too much power; the danger is the polarization of America.”

Read more:

John McCain’s brutal rejoinder to Sean Spicer

Senators from both parties pledge to deepen probe of Russia and the 2016 election

John McCain is quickly becoming Trump’s chief antagonist in the Senate