John McCain held Donald Trump in deserved contempt, and Trump mocked and detested him in return. But in a sense, Trump is one of the best things that ever happened to McCain. He gave the senator from Arizona so many chances to display his admirable qualities that you could forget he had others.

There is no denying McCain's sterling virtues: bravery, service to his country, bipartisan spirit, candor, indomitability, and more. His 2008 campaign yielded two moments that showed him at his best. The first was when he corrected a woman who told him Barack Obama is "an Arab." The second was his gracious concession speech on election night.

But overall, his time as the Republican nominee exposed a different side of McCain that should not be forgotten, even as the nation mourns his passing. Often his campaign was nasty, dishonest, and irresponsible. Worse, it helped turn the Republican Party into a vehicle that could be commandeered by Donald Trump.

The demonization of Obama that plagued his presidency didn't begin on Inauguration Day. It was part of the 2008 GOP campaign, and McCain was more than complicit. He was more than happy to question his opponent's patriotism and disparage his integrity.

When Obama disagreed with his opposition to a bill expanding education benefits for veterans, McCain replied with sanctimonious scorn: "I will not accept from Sen. Obama, who did not feel it was his responsibility to serve our country in uniform, any lectures on my regard for those who did." McCain had voted to confirm Dick Cheney as secretary of defense even though he got five deferments to avoid Vietnam.

Because Obama favored withdrawal from Iraq, McCain claimed his rival "would rather lose a war in order to win a political campaign." Sen. Chuck Hagel, a decorated Vietnam veteran and Nebraska Republican, rebuked McCain for stooping to this smear.

Rick Wilson, a Republican consultant, praised McCain's attacks: "Obama is always going to struggle with the cultural disconnect. He scans very much as liberal Ivy League elitist. People automatically put him in a box with people who are not like Middle America's view of patriotism." Rep. John Lewis (D-Ga.), whom McCain revered for his courage in marching for civil rights, accused him of "sowing the seeds of hatred and division."

After slamming Obama for his inexperience, McCain put the country at risk of Sarah Palin, who lacked not only experience but basic knowledge of issues. Her ignorant demagoguery was practically a blueprint for Trump's campaign—and when Trump came along, McCain's running mate campaigned for him.

But McCain's examples of grievous misjudgment didn't begin or end with the campaign. In 2003, he predicted that "when the people of Iraq are liberated, we will again have written another chapter in the glorious history of the United States of America."

This year, McCain finally acknowledged that the war "can't be judged as anything other than a mistake, a very serious one, and I have to accept my share of the blame for it."

But it was a limited lesson, learned late. He was a tireless advocate of military intervention in foreign conflicts, including Libya and Syria. He favored a pre-emptive strike to prevent Iran from getting nuclear weapons and opposed the Iranian nuclear deal.

McCain was wrong on many issues. He opposed allowing gays to serve openly in the military. He opposed George W. Bush's tax cuts partly because they would produce "growing deficits"—and, after they did exactly that, voted to extend them. A champion of humane immigration policy, he changed course in 2008, saying he would vote against his own bill.

Among his favorite crusades was campaign finance reform. But the Supreme Court ruled that major sections of the McCain-Feingold law violated the First Amendment.

Not only that but it didn't clean up our elections. Opponents warned that by barring large individual and corporate contributions to political parties, "it would precipitate a tectonic shift of political power away from the parties and toward outside groups, which were likely to be far more extreme and far less accountable," wrote Robert Kelner and Raymond La Raja in 2014 in The Washington Post. "The critics were correct." It's another way the foe of Trump facilitated the rise of Trump.

McCain, a far wiser statesman and a far better human being than this president, fully earned the praise being bestowed on him. But for the process that brought America to its current disgrace, McCain also earned a share of the blame.