Sen. John McCain (R-Ariz.) shakes hands with former vice president Joe Biden after receiving the Liberty Medal in Philadelphia on Monday. (Matt Rourke/AP)

John McCain and Joe Biden have been on opposite sides of many crucial national security debates over the past 30 years.

From Iraq to Afghanistan to Syria, the Arizona Republican and the Delaware Democrat clashed over the scope of the American military mission and the efficacy of reaching for diplomatic resolutions for these war-torn nations. They maintained a genuine friendship through 22 years of service together in the Senate and then Biden's eight years as vice president. Yet theirs was a fierce, principled rivalry.

On Monday night, in the cradle of liberty, those disputes disappeared as Biden presented the Liberty Medal to McCain at the National Constitution Center, a nonprofit organization that touts bipartisanship and sits across the street from Independence Hall.

Another reality has also brought them together: President Trump, whose global outlook has helped crystallize just how closely aligned these two elder statesmen really are.

"We believed in our country, and in our country's indispensability to international peace and stability and to the progress of humanity," McCain said, growing unusually emotional at times during the address.

McCain pivoted into a full-frontal attack on those who "refuse the obligations of international leadership and our duty to remain 'the last, best hope of earth' for the sake of some half-baked, spurious nationalism." He did not mention Trump by name, but the implication was clear, and it brought a standing ovation from a crowd that included Democratic and Republican members of Congress from the region.

The event helped illustrate the rapidly changing ideological fault lines, under Trump, on national security.

No longer was the divide between those who wanted to engage the world through brute force and those pushing for more diplomacy. Now, McCain and Biden are on the same side, battling the isolationism that Trump has avowed and that has been most clearly articulated by his onetime chief strategist, Stephen K. Bannon.

In his first nine months in office, Trump has withdrawn the United States from a Pacific Rim trade deal, the Paris climate accords and a cultural organization at the United Nations, while also signaling opposition to the Iran nuclear deal and new sanctions against Moscow.

Some of these moves have found support from Republicans, including McCain, but overall they reveal Trump's broad intention to live up to his "America First" presidential campaign of 2016 — a repudiation of all that McCain and Biden have pressed for 40 years.

McCain spent the first half of the year crisscrossing the globe trying to reassure the country's longtime allies, a theme he repeated Monday in Philadelphia.

"We will not thrive in a world where our leadership and ideals are absent. We wouldn't deserve to," he said.

The speech prompted the president to issue an immediate threat: "People have to be careful because at some point, I fight back," Trump said in an interview Tuesday with WMAL, a D.C. radio station.

But it's a different fight now. McCain has onetime foes staunchly on his side, as Biden used the most personal terms possible to describe his respect for the ailing senator.

"I want to say, John, how much your example of service and duty, courage and loyalty, inspired my Beau," Biden told the crowd, speaking of his late son's decision to serve in 2008 with his Army National Guard unit in Iraq. "John, when he received his cancer diagnosis, he also found strength in the courage you've demonstrated throughout your whole life."

Beau Biden died in 2015 after losing his battle with glioblastoma, the same form of brain cancer that McCain was diagnosed with in July. It's a cruel twist in their long friendship, one that they share with their mutual close friend, the late Edward M. Kennedy (D-Mass.), who died in 2009 from the same disease.

McCain wiped away tears as Biden spoke of his son's adoration for the Arizona senator, a symbolic forging of their alliance. They will, for now, set aside their old disputes on how to engage the world and instead take up a mutual fight against those who want to withdraw from global leadership.

The bygone battle lines came from their upbringings and early decisions as senators. The son and grandson of Navy admirals, McCain, 81, was destined for a life in the military. When he arrived in the Senate in 1987, he aimed his sights on eventually becoming the chairman of the Senate Armed Services Committee, overseeing the Pentagon.

The son of a used-car salesman, Biden, 74, always believed that he could talk anyone into a deal. In the Senate, his highest honor came as Foreign Relations Committee chairman, overseeing the State Department.

As the Iraq War unraveled in 2006, McCain pushed for a military answer, for a "surge" in troops to beat back the insurgency and hold onto reconquered territory. Biden pushed a diplomatic solution of partitioning the nation, trying to separate the warring clans into different regions.

At the end of 2009, McCain backed the generals who were pushing for a massive surge of more than 40,000 troops in Afghanistan, while Biden counseled then-President Obama to go with a lighter footprint and search for a political settlement in the divided country. Obama split the difference.

In December, during a day of tribute to Biden in the Senate, McCain made light of their many disagreements. "In the persistent triumph of hope over experience, we both still cling to the expectation that we can persuade the other that he is mistaken. I think, deep down, we probably know better," McCain joked.

The two men set aside those disputes Monday, and perhaps for years to come, as they forged a new partnership to fight Trump's inclination to pull back the U.S. presence on the global stage. Biden read from an old McCain speech to sum up the new approach, saying that the United States should always be an "international beacon of liberty and a defender of the dignity of all human beings, and the right to freedom and justice."

"That's what it's always been for four decades," Biden said.

Read more from Paul Kane's archive, follow him on Twitter or subscribe to his updates on Facebook.