Sen. John McCain, who passed away Saturday from brain cancer, penned a farewell message before he died that appears to take thinly veiled shots at President Donald Trump for fanning the flames of "tribal rivalries" and hiding "behind walls."

The moving message, a personal tribute to America and its people, was read to the public Monday by Rick Davis, a close friend of McCain's and the national campaign manager of the Arizona Republican's 2008 and 2000 presidential campaigns.

Speaking of country's best qualities, McCain wrote that "we weaken our greatness when we confuse our patriotism with tribal rivalries that have sown resentment and hatred and violence in all corners of the globe."

"We weaken it when we hide behind walls, rather than tear them down, when we doubt the power of our ideals rather than trust them to be the great force for change they have always been," Davis, holding back tears, said as he read McCain's message in Phoenix.

"Do not despair of our present difficulties but believe always in the promise and greatness of America, because nothing is inevitable here," McCain wrote. "Americans never quit. We never surrender. We never hide from history. We make history."

The message, which Davis described as McCain's "final words," did not mention Trump by name but it appeared clear whom some of the remarks were aimed at.

"We are 325 million opinionated, vociferous individuals. We argue and compete and sometimes even vilify each other in our raucous public debates. But we have always had so much more in common with each other than in disagreement," McCain added in the statement.

"If only we remember that, and give each other the benefit of the presumption that we all love our country, we will get through these challenging times. We will come through them stronger than before. We always do," Davis read, repeatedly taking breaks for water and choking back emotion.

READ: McCain's full farewell statement

In his final statement, McCain also offered his gratitude to the people of America, his constituents in Arizona, his family and "to America."

"To be connected to America's causes — liberty, equal justice, respect for the dignity of all people — brings happiness more sublime than life's fleeting pleasures," McCain wrote. "Our identities and sense of worth are not circumscribed but enlarged by serving good causes bigger than ourselves.

"'Fellow Americans' — that association has meant more to me than any other. I lived and died a proud American."

The statement marked one final — yet graceful — blow at Trump, who had repeatedly insulted McCain since the launch of his presidential campaign in 2015.

That year, Trump said McCain, who endured torture after his Navy plane was shot down in Vietnam, was "not a war hero." "I like people that weren't captured," Trump said.

In October 2016, McCain pulled his support for Trump's presidential bid after a 2005 recording was released in which Trump can be heard boasting about grabbing and kissing women without their consent.

The rough-and-tumble between the two men only got rougher after Trump was sworn in as president, with Trump lambasting the senator for his vote against repealing Obamacare and McCain hitting the president on his Muslim ban, lack of experience, impulsiveness and relationship with Russian President Vladimir Putin.

In what many perceived as yet another insult, Trump, following McCain's, sent only a brief tweet to offer his condolences, instead of a longer statement.