But as the Arizona senator, like Shakespeare’s John of Gaunt, spent his twilight years raging against the coarsening of civic life, he must have been aware that his legacy would include a decision that helped unleash the very forces he came to despise.

Wednesday marks the 10th anniversary of McCain unveiling Sarah Palin, a say-anything, gun-toting political neophyte, as his running mate in the 2008 presidential election. It was an act of political desperation that left Washington aghast. It delivered a short-term boost in the polls. But it also opened the Pandora’s box of populism.

Looking back at the day in Dayton, Ohio, as the crowd roars while McCain’s face is frozen in rictus, the moment is freighted with portents of a decade in which his beloved Republican party would slip from his grasp. It is a premonition of what many in America and around the world have come to regard as the horror of Trumpism.

The Palinisation of politics kind of started there. It hasn’t been the best for the Republican party

Senator Jeff Flake

“I don’t think he could have known it at the time but he took a disease that was running through the Republican party – anti-intellectualism, disrespect for facts – and he put it right at the centre of the party,” David Brooks, a New York Times columnist, told the recent HBO documentary John McCain: For Whom the Bell Tolls.

It is now easy to forget that in September 2008, McCain enjoyed a four-point lead over Barack Obama. Some analysts were sceptical that, given its tormented racial history, America would be willing to elect a black person to its highest office. Despite George W Bush’s unpopularity, the next Republican nominee had a pretty good shot at winning the White House.

In a memorable moment from the campaign – much replayed in TV tributes after his death on Saturday – McCain is seen admonishing a supporter at a rally in Lakeville, Minnesota, who refers to Obama as an “Arab”. The senator shakes his head, takes the microphone and says firmly: “No ma’am. He’s a decent family man, citizen, that I just happen to have disagreements with on fundamental issues and that’s what this campaign is all about.” The crowd applauds.

'American original': John McCain praised by political friends and foes

Read more

But what received less coverage was another incident at the same rally in which a supporter says he is “scared” by the prospect of a Obama presidency. Again, McCain replies with integrity, insisting: “He is a decent person and a person that you do not have to be scared as president of the United States.” But on this occasion, the crowd boos and jeers in what now sounds like a pre-echo of a Trump event.

A New York Times report of the rally paints a more complicated picture. McCain criticised Obama, it says, for associating with the 1960s radical William Ayers, claiming: “Mr Obama’s political career was launched in Mr Ayers’ living room.” McCain had spent the week “trying to portray Senator Barack Obama as a friend of terrorists who would drive the country into bankruptcy”, the paper notes, running campaign ads that hammered Obama as a “liar”.

On election night itself, McCain’s conduct was beyond reproach as he conceded defeat with singular graciousness. However, when he announced that he had just called Obama to offer congratulations, the crowd booed, and McCain was forced to beg: “Please.” Later, when he referred to Obama leading the country for the next four years, there were more boos and another entreaty of “Please, please”.

From the vantage point of 2018, it looks and sounds like a member of the old guard fighting to hold back the populist tide – a tide that would eventually overwhelm both his party and nation.

And that tide was amplified by the selection of Alaska governor Palin as nominee for vice-president. She told the Republican convention: “I love those hockey moms. You know, they say the difference between a hockey mom and a pit bull? Lipstick.” Her gaffes were quaint by Trumpian standards, but she had little grasp of policy, accused Obama of “palling around with terrorists” and paved the way for a grievance-fuelled, celebrity-driven politics, later appearing in a reality TV show and as a pundit on Fox News.

McCain came to realise that it was a terrible mistake. In the HBO documentary, filmed as he was dying from brain cancer at his ranch in Sedona, Arizona, he made a last confession. He said he regretted not choosing then senator Joe Lieberman, a Democrat turned independent, as his running mate. “I should have said: ‘Look, Joe Lieberman is my best friend, we should take him.’ But I was persuaded by my political advisers it would be harmful, and that was another mistake that I made.”

Jeff Flake, McCain’s Republican colleague from Arizona, told the Guardian: “He regrets not going with his instinct on that, which would have been Lieberman. I don’t know if it would have made the difference in that election but the Palinisation of politics kind of started there. It hasn’t been the best for the Republican party, I will say, but I don’t think he could have known. She was more a symptom of it than anything else.”

Subsequent years brought anti-Obama obstructionism, the rise of the Tea Party and a toxic mix of cultural and economic resentment. What had seemed angry but marginal voices at those McCain campaign events moved centre stage in the Republican party and found an unlikely tuning fork in a New York billionaire and reality TV star.

Trump launched his presidential campaign in June 2015 and soon caused consternation by denying that McCain was a “hero”, saying he preferred heroes who were not captured. In January 2016, Palin endorsed him for president. Once Trump’s character became clear, McCain spent every last ounce of his energy resisting him.

John McCain obituary

Read more

Just days after his diagnosis in July last year, he ignored medical advice and flew from Arizona to the Senate to vote down a Trump-backed plan to scrap Obama’s signature healthcare law. In October, he lambasted the president’s foreign policy as a “half-baked, spurious nationalism cooked up by people who would rather find scapegoats than solve problems”. And last month, when Trump refused to back his own intelligence agencies over Russian president Vladimir Putin in Helsinki, McCain described it as “one of the most disgraceful performances by an American president in memory”.

And yet, future historians seeking to understand the man and his time will surely revisit that day in Dayton, when McCain forced a smile and introduced “the next vice-president of the United States, Governor Sarah Palin of the great state of Alaska”. They will consider what it foretold, and ponder why a man of decency and honour opened the door to demagoguery in America.