Sixteen years before Donald Trump took on the Republican Party establishment and its Bush-family vehicle, a candidate named John McCain likewise took on both. We needn’t force the parallels between the two men—who detested each other to the extent that Trump is off the guest list for McCain’s funeral—to note that McCain’s campaign anticipated Trump’s in its use of strategic bluntness and defiance of G.O.P. orthodoxies. That McCain failed where Trump succeeded was to a large degree a problem of timing as much as message: Republican voters hadn’t yet come to hate their leaders.

Today, in the wake of the sad news that John Sidney McCain III has succumbed to cancer, we’ll hear talk of the passing of a certain breed of politician: the war veteran, the bipartisan, the sane Republican, and the like. Such statements will be sentimental more than true, however, for Republicans still have plenty in their ranks who correspond to such labels, and McCain was a lot knottier than his champions care to admit, remaining unpredictable to the last. The battles within him between party acclaim and popular acclaim, expedience and principle, prudent courage and reckless courage seemed to keep raging. And timing, as often as time, seemed to be his principal foil.

In 1999, when McCain announced his run for the presidency, he was a respected senator, but also, to some extent, a politician on the mend. A decade earlier, he had been named as one of the “Keating Five,” a group of senators who were alleged to have pulled strings for savings-and-loan fraudster Charles Keating in 1987, and nearly two years of ethics investigations had followed before McCain was cleared, albeit with some rebukes for poor judgment. The terror of a possible loss of career and reputation had helped to transform McCain into one of the Senate’s leading voices in favor of campaign-finance reform, and his run for the presidency, launched with a best-selling memoir that told the story of McCain’s years as a prisoner of war in a North Vietnamese camp, further cleaned the slate.

Then the love affair began. In the late months of 1999, McCain became the darling of the left, right, and center. He was a war hero who had survived five and a half years as a P.O.W. in Vietnam. He was conservative, but only mildly so on social issues, and dismissive of the religious right. He was strict on fiscal issues, and largely indifferent to tax cuts. On his campaign bus, called the “Straight Talk Express,” he showed an openness, humor, and bluntness that won over just about everyone who spent time on it. One such person, a bemused but enchanted Tucker Carlson, noted in The Weekly Standard that the average political reporter inevitably concluded that “John McCain is about the coolest guy who ever ran for president.” Dana Milbank could agree. Jon Stewart could agree. No one wanted Bush to win, except for the donors and the religious right—but those, as it turned out, outnumbered the McCainiacs.

Today, the old fan club is dissolved and scattered, and you’ll find former McCainiacs among the neocons, the deplorables, the Clintonites, and the Bernie Bros. This isn’t as odd as it might look. The rebellion that McCain represented back in 1999 and 2000 was precisely what much of the country desired at the time, when Americans generally supported the policies of Bill Clinton, if not the man himself. Republicans were careful to tack to the center in their rhetoric, and the stakes seemed lower. Issues such as immigration and war and trade were divisive, but not wrenchingly so. The jobs weren’t yet gone; 9/11 hadn’t happened; our banks hadn’t yet collapsed. The preoccupations of people like Bernie Sanders and Pat Buchanan seemed eccentric. Rebelling against the G.O.P. establishment in 1999 meant defying the donor class on taxes and the religious right on social issues. But rebelling against it in 2016 meant defying the donor class on trade and immigration and siding with the religious right on social issues. The makeup of the Establishment had changed, and McCain had become part of it. His earlier fans sorted themselves accordingly.

If McCain, at times, seemed bitter, perhaps these immense shifts had something to do with it. Politicians, more than most people (albeit less than pop stars), learn to cope with swings in the public mood, but those who have enjoyed a period of marked resonance, when everything they say triggers sympathetic reverberations with the masses, have it hard when that stretch runs out. You can recognize that stardom is evanescent, yet still yearn to get it back. McCain was going fairly strong in 2004, when John Kerry was trying, without success, to entice him into joining the Democratic ticket, but the formula of 2000 could no longer work. What remained instead were unpalatable choices. He could give up on a presidential run, or he could make nice with the Republican Party. McCain chose the latter, and from 2004 on became a loyal partisan, lining up behind his party and president. Unfortunately, this was like chaining oneself to Three Mile Island. Both Bush and his party were becoming ballot-box poison.

By the time McCain finally secured a presidential nomination, in 2008, it was at exactly the wrong time. What everybody wanted—peace, a break from Bush-era policies, and a fair and sensible way out of a financial crash—McCain couldn’t offer. What he could offer, resolute leadership in war, nobody wanted. He may have gotten somewhere by taking a righteous stance against bailing out the banks, but such heterodoxy wasn’t in him. He understood very little about economics, anyway.

The campaign that year wound up showing McCain at his best and worst. To the consternation of many Republicans, he eschewed all advice to hit Barack Obama for his association with radical preacher Jeremiah Wright. He made a proposal to the Obama campaign that the two candidates do 10 town halls together, and the idea, while self-serving, was still wonderful. McCain also stuck to his pledge, one that was broken by Obama, to use public financing for his campaign. At the same time, McCain shocked many of his admirers by picking as his running mate Alaska Governor Sarah Palin, someone exceptionally unsuited to the role. Palin’s virtues (sense of humor, love of country, informality) were entirely inadequate in the face of her vices (insecurity, ignorance, self-deception), all of which were brought out under the glare of a national campaign. It made McCain look reckless and cynical.

After 2008, McCain managed to frustrate nearly everyone. Democrats became enraged when McCain joined his fellow Republicans in partisan politics to weaken Obama. Republicans became enraged when McCain voted to confirm nominees or pass immigration amnesties. Because he broke ranks, because he was independent at one moment yet partisan the next, people tried to impose defamatory theories on him to make the pieces line up. Some Democrats found it easiest just to call McCain a phony and a hack. Some Republicans found it easiest to say McCain was actuated by sanctimony and spite. In the far-rightish world, you could even read lengthy arguments that McCain had been a stooge of the Viet Cong. Each theory had very little predictive power, however. A simpler explanation is that McCain, while at times expedient or partisan, preserved more independence of mind than is customary in his trade.

For better or worse, the strongest clues to McCain’s outlook are to be found in the writings of one of his idols, Winston Churchill. To read Churchill’s writings, especially on the Second World War, is to be seduced by both elegant presentation and vocal principles. But one danger of Churchill worship is that of hearing an echo of the 1930s in every foreign conflict. Yes, Vladimir Putin is a rogue, and grabbing Crimea from Ukraine was illegal. But was it really a replay of Hitler grabbing the Rhineland? McCain seemed to think so. Everything was a replay of Hitler grabbing the Rhineland.

Such hawkishness became increasingly unwelcome among voters as U.S. interventions seemed to amplify the problems they were intended to forestall: terrorism, tyranny, nuclear proliferation. This is one reason why Trump, whatever policies he might pursue in practice, gained political ground when he campaigned on themes of nationalism and, at least implicitly, non-intervention. It’s also why McCain and Trump were bound to clash, even if things hadn’t gotten personal. McCain considered the role of the United States as global leader to be sacred, and he dismissed the idea of self-contained nationalism as a “tired dogma of the past.” But who was the one upholding a tired dogma of the past?

Personal assessments of McCain differed, but seemed to stack up highest in the favorable column. While some disliked him and considered him to be a hotheaded bully, most described a man of magnanimity, humor, and courage. That last quality was especially important to McCain, and he wrote a book about the subject. As one might expect, McCain quoted Churchill quite a bit, and much of the content was self-serving, as such things will be, but it also seemed to come from the heart. McCain could be maddeningly inconsistent and often dangerously wrong, but thinking often about courage made him abler than most to exhibit it. He understood that standing for something can be costly, and this led him to make some unpopular decisions, whether they were right or wrong. Many politicians are agreeable people who lack the core that’s required for true goodness. McCain was a not-so-agreeable person who seems to have had that core. This made him important, interesting, flawed, and confusing. In a trade that tries to stamp out the edges of normal human behavior, McCain, for better or worse, kept his. If only more of us did the same.