John McCain, surrounded by journalists as always, on his way to the Senate floor for a vote on Elaine Chao’s nomination as transportation secretary in January 2017. (Melina Mara/The Washington Post)

Reporters liked covering Sen. John McCain, and John McCain seemed to love being covered by them. Most politicians tend to see peril in too much press, but McCain actually encouraged reporters to hang around.

He sensed he could turn it to his advantage. Indeed, McCain may have saved his political career with his ability to snake-charm journalists.

The Arizona Republican, who died on Saturday at 81, was easy for journalists to like. He was plain-spoken, self-deprecating and always in possession of an amusing anecdote or quip. (An oft-repeated McCain gag: He had become so close to former senator Joe Lieberman, an Orthodox Jew, that he wanted to convert to Judaism — until Lieberman reminded him he’d have to have a bris.) McCain had a legendary backstory, too: His esteemed military family, his service as a Naval pilot and his imprisonment and torture in a North Vietnamese prison camp.

But his relationship with the news media may have been cemented by the thing that always wins a journalist’s heart: He was accessible and available.

“You could always find him,” said Bob Schieffer, the longtime CBS newsman and former host of “Face the Nation” who first met McCain when McCain was a Naval liaison on Capitol Hill in the late 1970s. “Most politicians, when the news is good, you have no trouble finding them. When it’s bad, you can’t find them with a bloodhound. McCain was always around and always willing to come on and talk. And he always had something to say.”

McCain set the record for most appearances on “Face the Nation,” an astonishing 112. He appeared 73 times on “Meet the Press,” a record for that program.

During his first run for president in 2000, McCain regularly invited journalists onto his campaign bus, and talked freely with them, sometimes for hours. (McCain’s campaign branded the bus the “Straight Talk Express.”) He occasionally hosted the press at his Arizona ranch.

In the Senate, he made a habit of sauntering down the corridor and waiting for reporters to gather around him, which they invariably did. He reliably returned reporters’ phone calls, a godsend on deadline.

The media friendliness helped McCain polish his image as a “maverick” willing to buck Republican orthodoxy on issues such as immigration and campaign-finance reform. He knew it brought a big return on investment in the form of favorable stories; McCain jokingly called the news media “my base.”

The “base” has returned the affection in the hours since McCain’s passing. The outpouring of fond tributes attests to his standing among journalists.

“McCain was a throwback to a time when it was relatively easy” for reporters to get to know a candidate, said Mark Leibovich, a former Washington Post reporter and now chief national correspondent for the New York Times Magazine who profiled McCain several times. “He would allow it, encourage it, enjoy it and was also fully aware of the shtick involved with it, the idea that ‘Hey, here we all are hanging around with John McCain.’ The he’s-such-a-straight-talker thing was itself a Washington cliche.”

McCain, he said, “operated on many levels of irony, often several levels deeper than most of the media people who were partaking of the show and writing about him. . . . I feel lucky to have been able to write about him as many times as I did, and also get to hang around with him as much as I did during those forays. I have a million little goofy stories I remember.”

McCain wasn’t always the happy warrior. He could be a curmudgeon and critic in his many sessions with reporters, gleefully marinating in his own outrage. He had lots of harsh things to say about President George W. Bush’s handling of the war in Iraq and his use of prisoner-interrogation methods that McCain considered torture, and therefore immoral and un-American. He regularly scolded President Obama on Obamacare and most foreign-policy issues.

This dyspeptic side was occasionally aimed at reporters. McCain nursed a long grudge against the New York Times over an article it published at a critical point in the 2008 presidential campaign. The story strongly implied that McCain had an affair with a female lobbyist, an assertion vigorously denied by both parties. After the lobbyist, Vicki Iseman, filed a libel suit, the Times agreed to print a note to readers saying the story “did not state, and The Times did not intend to conclude, that Ms. Iseman had engaged in a romantic affair with Senator McCain or an unethical relationship on behalf of her clients in breach of the public trust.”

McCain later told Leibovich, “I will never forgive the New York Times for what they did.”

Yet McCain learned relatively early in his political career that good press relations could be more than just a career enhancer: It could save his entire career.

McCain actively courted the press to help him surmount his greatest political disgrace — his membership in “the Keating Five,” a group of senators accused of improperly intervening with federal regulators in behalf of a campaign donor, Charles Keating, to save his failing savings and loan from a federal takeover.

As the scandal mounted in 1989, just two years into his first term as senator, McCain “employed a dual strategy,” wrote Dan Nowicki and Bill Muller of the Arizona Republic in a 2007 retrospective. “He would make himself accessible to any reporter anywhere who wanted to talk about the Keating Five, and he wouldn’t let the controversy detract from his work as a senator.”

McCain’s “hobnobbing with the press had an unexpected side effect,” they wrote. “Reporters started to like him. . . . For Beltway reporters bored with bureaucrats, McCain was fresh, new and different.”

When the Persian Gulf War broke out in 1991, McCain — the Naval fighter pilot and Vietnam War hero — was in demand as a TV talking head. “The ‘Today’ show called, and we started on the ‘Today’ show at four-something in the morning,” recalled Scott Celley, a former aide, in the Arizona Republic article. “The last thing I remember him being on was Australian Nightline . . . at close to 11 p.m. He was on television or the radio every minute of that day.”

The Keating scandal gradually began to fade. Expected to face a tough reelection campaign in 1992, McCain instead won easily, attracting 56 percent of the vote in a race that included a former Arizona governor, Evan Mecham, a Republican who ran as an independent. On Election Night, McCain told the Arizona Republic: “I think this puts the [Keating scandal] behind me, yes, politically.”

McCain lost his two runs for president but won reelection to the Senate four more times. With each campaign, the legend of Mr. Straight Talk grew immeasurably larger.

“He understood what my job was,” said Schieffer. “He welcomed the hard questions. If I asked him a zinger, he’d get a kick out of it.”

“The good ones aren’t afraid,” continued Schieffer. “When you spend 5½ years in a prison camp, you’re not going to be cowed by some reporter asking you a tough question.”