Get the latest from TODAY

Sign up for our newsletter
/ Source: TODAY
By Julie Pennell

Former President Barack Obama may have competed against Sen. John McCain in the 2008 presidential election, but that didn’t stop him from remembering and praising the late Arizona senator, who died from brain cancer at the age of 81 on Saturday.

John McCain and Barack Obama
2008 Presidential Democratic nominee Barack Obama and Republican nominee John McCain shake hands at the end of their third presidential debate.Win McNamee / Getty Images

“John McCain and I were members of different generations, came from completely different backgrounds, and competed at the highest level of politics,” Obama, 57, wrote in a statement posted on Twitter Saturday evening. “But we shared, for all our differences, a fidelity to something higher — the ideals for which generations of Americans and immigrants alike have fought, marched, and sacrificed.”

During the campaign, the two were gracious and respectful of each other even as they battled it out for the presidency.

At the 2008 Alfred E. Smith Memorial Foundation Dinner, a white-tie fundraiser held less than a month before election day, McCain spoke kindly about Obama, saying, “My opponent is an impressive fellow in many ways. Political opponents can have a little trouble seeing the best in each other. But I have had a few glimpses of this man at his best, and I admire his great skill, energy and determination."

He added, “I can’t wish my opponent luck, but I do wish him well.”

Another memorable moment on the campaign trail was when a voter told McCain she couldn’t trust Obama because “he’s an Arab.” McCain took the microphone away from her and shook his head. “No ma’am," he said. "He’s a decent family man and citizen that I just happen to have disagreements with on fundamental issues, and that’s what this campaign’s about.”

Obama continued in his statement that they saw their political battles as a privilege and something noble, adding, “We saw this country as a place where anything is possible — and citizenship as our patriotic obligation to ensure it forever remains that way.”

John McCain and Barack Obama
Thirteen days after winning the election, President Barack Obama met with John McCain at his transition offices in Chicago.Saul Loeb / AFP/Getty Images

McCain, a Navy veteran who spent more than five years in a prisoner of war camp during the Vietnam War, was also praised by Obama for his courage.

“Few of us have been tested the way John once was, or required to show the kind of courage that he did,” Obama wrote. “But all of us can aspire to the courage to put the greater good above our own. At John’s best, he showed us what that means. And for that, we are all in his debt.”

He closed the statement by saying, “Michelle and I send our most heartfelt condolences to Cindy and their family.”

A source confirmed to NBC News that Obama and former President George W. Bush will deliver eulogies at McCain's funeral, however the late senator made it clear before he passed that he did not want President Donald Trump, with who he’s had a turbulent relationship, to attend. Trump tweeted his sympathies and respect to McCain’s family on Saturday night.