WASHINGTON — In any presidential campaign the job of a running mate is typically to play attack dog. But in the fall of 2008, it seemed that nearly every Joe Biden attack on the Republican ticket required a preamble of praise for his longtime Senate colleague, John McCain.

“The personal courage and heroism demonstrated by John still amazes me. But I profoundly disagree with the direction John wants to take this country,” Biden said as he accepted the nomination to be vice president at the Democratic convention in Denver.

The deference became something of a running joke to the reporters traveling with Biden, so one day they brought on board the campaign plane a life-size cardboard cutout of the GOP presidential nominee. When Biden encountered it, though, the normally affable candidate turned serious — making it clear his friendship with McCain would not be made light of for a campaign stunt.

The decades-long friendship between McCain and Biden, having endured no shortage of battles on policy in the Senate, lasted well beyond a presidential campaign that saw them on opposing tickets.

And it’s an uncommon bipartisan bond that will be showcased Thursday as the former vice president delivers the closing tribute at a memorial service in the late senator’s honor in Phoenix.

McCain had personally asked Biden to deliver a eulogy when the two met for the final time, in April at the senator’s Sedona ranch. Biden “is being treated as a member of a family,” McCain’s former campaign manager Rick Davis said this week in discussing the funeral plans.

“If there’s a better of exemplification of debating and throwing a few punches, but at the end of the day being able to maintain a relationship with the people you are at battle with, as the model of governance John McCain adhered to, that relationship with Biden was in the category,” Davis said.

Biden has spent the past few days working on the tribute at his Delaware beach house with close aides, who say the remarks will focus on their enduring personal bond, Biden’s deep respect for the code McCain lived by, and a legacy of service that stands as an example in this tumultuous political era.

Biden and McCain served as colleagues in the Senate for two decades, after McCain joined the chamber in 1987.

But the seeds of their friendship were planted more than a decade earlier. In 1973, Biden was just months into his first Senate term and still dealing with the pain of losing his wife and young daughter in a car crash when he saw news coverage of a Naval pilot returning home after years in Vietnam as a prisoner of war. Biden turned to an aide, Ted Kaufman, and remarked, “Someday I want to meet that guy.”

Just years later he had the chance, when then-Capt. John McCain took a post as the Senate Liaison Officer for the Naval Legislative Office. His duties included escorting senators during congressional delegations — or CODEL — overseas. During a tribute in the Senate to Biden as his vice presidency came to an end in 2016, McCain recalled one of the many trips he made with Biden in that capacity. One late night a military liaison — “that rascal, whoever he was” McCain joked — was seen dancing on a table top with Biden’s wife, Jill.

“He was lucky the senator whose spouse he made endure the awkward moves he euphemistically called ‘dancing’ was Joe Biden. Few other senators would have seen the humor in it,” McCain recalled.

Biden has said he was among those who encouraged McCain to enter politics himself. And when McCain joined him in the Senate they became friends and frequent sparring partners.

“Joe Biden and John McCain could go at it like the hammers of Hades,” said Kaufman, who would later also serve as Delaware senator after Biden became vice president. “They had very different opinions on a lot of important issues. But it never once, never once, never once affected the way he felt about John McCain.”

After leaving the White House, Biden remained in close contact with McCain and was one of the first to call him after he announced his diagnosis with a form of brain cancer — the same disease that killed Biden’s eldest son, Beau. If not with McCain himself, Biden would speak at least every other week with his daughter, Meghan, to discuss his condition and ongoing treatment.

“Biden has been a comfort to the family, and a source of information to the family about the disease when he was first diagnosed. And I know the whole family have been comforted by his prayers and council,” Davis said this week.

Sen. John McCain and former Vice President Joe Biden on Oct. 16, 2017. Matt Rourke / AP file

They last shared a stage publicly in October 2017, when Biden presented McCain with the National Constitution Center’s Liberty Medal. Biden told McCain that his son had drawn strength from McCain’s example of courage as a POW and his continued public service.

McCain then delivered remarks that served as a stinging rebuke of President Donald Trump, vowing that the United States would “abandon the ideals we have advanced around the globe … for the sake of some half-baked, spurious nationalism cooked up by people who would rather find scapegoats than solve problems.”

Biden, who has not ruled out one final run for the presidency in 2020, has since quoted the line often in public speeches.