The political career of Sen. John McCain ended much like it began — with the Arizona Republican earning media attention for publicly challenging a president from his own party.

Before he was even sworn in to the House of Representatives, the newly elected McCain starred in a Dec. 1, 1982, UPI wire report about incoming congressional freshmen who were skeptical of President Ronald Reagan’s proposed increase in military spending.

“I'd like to see some testimony by experts before we spend $30 billion for this,” McCain was quoted as saying during a luncheon for GOP newcomers. “The people in Arizona are convinced that a great many of their tax dollars spent on defense are being wasted.”

McCain, who died Saturday at age 81 after battling brain cancer, ultimately built a far better relationship with Reagan than he did with the White House's current Republican occupant, Donald Trump. In a January op-ed in The Washington Post, McCain held up Reagan as the standard Trump fails to meet. The piece was headlined, “Mr. President, stop attacking the press.”

In McCain's later years, the press sometimes defended him, too. Cable news boiled with outrage in May after a White House communications aide's morbid comment about McCain's health leaked out of a private meeting. The aide, Kelly Sadler, said McCain's opposition to Trump's nominee to lead the CIA, Gina Haspel, did not matter because he was “dying anyway.”

As a candidate, Trump himself said McCain, a former prisoner of war in Vietnam, is “not a war hero.”

“I like people that weren't captured,” Trump said.

At the time, the front page of the New York Post declared, “Trump is toast after insult.” Trump, of course, was not toast, and the New York Post later endorsed him in the Republican presidential primary.

As Trump's political power caught up to and ultimately surpassed McCain's, the men became a frequent study in contrasts for the media.

New York Times columnist Frank Bruni recently wrote: “The fight isn’t really between two men. It’s between two takes on what matters most in this messy world. I might as well be blunt: It’s between the high road and the gutter. McCain has always believed, to his core, in sacrifice, honor and allegiance to something larger than oneself. Trump believes in Trump, and whatever wreckage he causes in deference to that god is of no concern.”

Trump might be the reality-TV showman, but McCain displayed his own flair for the dramatic.

“Wait for the show,” he told reporters on that suspenseful summer night last year when the fate of a Republican health-care bill hinged on how McCain would vote in his return to the Senate, having delayed treatment for the tumor detected two weeks earlier.

At 1:29 a.m., McCain approached the Senate clerk and gestured thumbs down, ensuring the bill's failure.

“Several people gasped,” Ed O’Keefe wrote in The Post. “Others applauded. Reporters dashed out to report the news.”

McCain built goodwill in the media through candor and accessibility. During his first White House bid, in 2000, McCain nicknamed his campaign bus the Straight Talk Express. A Newsweek report from March of that year described the rapport:

While George W. Bush flew above in a jet named Great Expectations — or in a quiet charter bus surrounded only by aides — McCain rattled happily along in the Straight Talk Express. Instead of hiding with his handlers, McCain wolfed down jelly doughnuts and gabbed with reporters who, contrary to modern campaign stereotypes, were friendly and forgiving. McCain was having the time of his life, cracking jokes and making fun of his own staff, who seemed to be along mostly for the ride.

McCain was not always a media darling — not in his own estimation, anyway. As the Republican presidential nominee in 2008, he sometimes complained that his Democratic opponent, Barack Obama, seemed to be the center of attention.

In July of that year, McCain released campaign ads called “Obama Love” — mash-ups of favorable TV commentaries about Obama. “McCain is seeking a way to wrest the headlines back from Obama,” the Guardian reported at the time, “and there is some media speculation that he could announce his choice of vice president this week.”

McCain did not make his pick until the following month, but he did make a headline-grabbing choice: Alaska Gov. Sarah Palin.

In a new book, McCain expresses regret over the Palin selection, writing that he wishes he had run instead with Joseph I. Lieberman, then an independent senator from Connecticut.

McCain is also sharply critical of Trump in the book, which together with an HBO documentary “amount to the senator’s final say on his career,” according to the Times’s Jonathan Martin, “and a concluding argument for a brand of pro-free trade and pro-immigration Republicanism that, along with his calls for preserving the American-led international order, have grown out of fashion under President Trump.”

McCain ensured that his message would continue to attract press coverage even after he was unable to deliver it in person.