McCain rarely disguised his distaste for Trump as the real estate developer ran for president on a platform that included attacks on immigrants and US allies. In July 2015, after then-candidate Trump rallied an estimated 15,000 in Phoenix and claimed to represent a "silent majority," McCain said Trump had "fired up the crazies" in his state. The battle was on.
By the end of that month, Trump had disparaged McCain's Vietnam War service, saying McCain was "not a war hero" despite spending more than five years as a POW and enduring torture.
"He was a war hero because he was captured. I like people who weren't captured," Trump said during a forum in Ames, Iowa.
Trump refused to apologise at the time, despite criticism from nearly every corner, and has never retracted the statement. He has occasionally told people that he does not regret the comment.
"The reality is that John McCain the politician has made America less safe, sent our brave soldiers into wrongheaded foreign adventures, covered up for President Obama with the VA scandal and has spent most of his time in the Senate pushing amnesty," Trump wrote in an op-ed for USA Today that month. "He would rather protect the Iraqi border than Arizona's."
McCain did eventually endorse Trump in 2016, then withdrew his support weeks before the election after release of an Access Hollywood tape where Trump is recorded bragging about assaulting women.
Trump's immediate and angry response: "The very foul mouthed Senator John McCain begged for my support during his primary (I gave, he won), then dropped me over locker room remarks!"
In office, McCain has supported much of Trump's economic and national security agenda, despite his misgivings about Trump's dismissive approach to traditional US alliances. But he has also shown frustration towards Trump's White House, dismissing nominees abruptly from his office or growing angry at senior West Wing aides.
McCain crossed the White House last year over the GOP attempt to repeal Obama's Affordable Care Act, and Trump has never forgiven him.
After the vote, Trump said that McCain voted no out of a personal vendetta against him and that he would never vote yes to something that helped Trump.
He repeatedly told advisers that McCain should step down from the seat and let the Republican governor appoint another senator. Trump has also told White House aides that his supporters are not big fans of McCain and boasted that he became president while McCain did not.
Trump's retelling of the healthcare vote, usually without mentioning McCain by name, has continued throughout the senator's more than year-long treatment for brain cancer. The 81-year-old's family said that he is discontinuing treatment.
"Obamacare, we got rid of the individual mandate, which is the most unpopular aspect," Trump said during a political speech this month in Utica, New York. "I would have gotten rid of everything, but as you know one of our, one of our wonderful senators said, 'thumbs down,' at 2 o'clock in the morning."
Trump's aggrieved references to the healthcare vote "never stops being gross," McCain's daughter Meghan wrote on Twitter in June.
"I've let him know several times that was beneath the office and it doesn't reflect well on him," Senator Lindsey Graham, a South Carolina Republican and longtime McCain friend, said of Trump's attacks. "He's an American hero by any stretch of the imagination, and I don't see how it helps the President."
Graham said Trump "feels like he helped McCain in his primary, and John is sort of picking on him."
In May, Trump and press secretary Sarah Huckabee Sanders declined to apologise for an aide's remark that McCain's opposition to Gina Haspel, nominee for CIA director, "doesn't matter" because "he's dying anyway."
The aide, Kelly Sadler, left her job the next month but White House aides said her departure was not a punishment for the remark. Trump told advisers he did not care if she apologised or not and was more determined to suss out who leaked the comments, calling advisers in for a West Wing scolding.
During occasional Oval Office conversations about McCain's health or status in the Senate, Trump would usually say nothing, current and former officials said. He grew angry regularly that McCain was portrayed as the "good guy" in the news media and he as the "bad guy," according to a former senior Administration official who spoke to Trump about McCain.
Trump has fumed to friends about McCain's role in receiving research compiled by a former British intelligence officer that alleged Russia had potentially compromising information about Trump. He has complained that McCain has criticised him over Russia and foreign policy, questioning his expertise and noting that he won the presidency and McCain did not.
"Even a remote risk that the President of the United States might be vulnerable to Russian extortion had to be investigated," McCain wrote in what he called his last book, The Restless Wave, published this year.
"I could not independently verify any of it, and so I did what any American who cares about our nation's security should have done. I put the dossier in my office safe, called the office of the director of the FBI, Jim Comey, and asked for a meeting," McCain wrote.
McCain's assessments became more withering the longer Trump was in office.
In August 2017, McCain denounced white supremacists who held a deadly rally in Charlottesville, Virginia, after Trump had said the event was attended by "fine people on both sides."
"White supremacists aren't patriots, they're traitors - Americans must unite against hatred & bigotry," McCain tweeted at the time.
In accepting the Freedom Medal at the National Constitutional Center in October, McCain condemned "half-baked, spurious nationalism cooked up by people who would rather find scapegoats than solve problems," a clear dig at Trump.
Asked about McCain's remarks the following day, Trump said "people have to be careful, because at some point I fight back."
"You know, I'm being very nice, I'm being very, very nice, but at some point I fight back and it won't be pretty," Trump said in a WMAL interview.
Not long afterward, McCain appeared to take a shot at Trump for avoiding the draft during the Vietnam War.
"One aspect of the [Vietnam] conflict by the way that I will never ever countenance is that we drafted the lowest income level of America and the highest income level found a doctor that would say that they had a bone spur," McCain said during an interview with CSPAN.
McCain did not mention Trump by name, but his meaning appeared clear. Trump received five wartime deferments, including one in which a doctor diagnosed him with bone spurs.
Finally in July, McCain pilloried Trump for his chummy performance alongside Russian President Vladimir Putin at a news conference in Helsinki, calling it "one of the most disgraceful performances by an American president in memory."
The US President had rhetorically embraced Putin and appeared to side with him over US intelligence officials on Moscow's aggressive election interference.
"The damage inflicted by President Trump's naivete, egotism, false equivalence, and sympathy for autocrats is difficult to calculate," McCain said. "No prior president has ever abased himself more abjectly before a tyrant."
Trump said nothing in response. As McCain spends his final days in Arizona, aides say, Trump is inclined to still say nothing at all.