A military flypast was performed with the squadron one plane short, to symbolise the dead senator.
Mr McCain graduated from the elite Naval Academy in 1958, later serving in Vietnam as a fighter jet pilot.
Family and friends were joined by his classmates and the current midshipmen for a service at the school's chapel.
It caps a week of memorials for Mr McCain, who died on 25 August, aged 81, from the effects of brain cancer.
John McCain will be buried next to an old friend, in the grounds of the US Naval Academy
On Saturday, heavyweights from across the political spectrum gathered at the Washington National Cathedral to remember the Arizona senator, who became one of America's most high-profile politicians.
Two former presidents - George W Bush and Barack Obama - paid tribute to Mr McCain's courage and sense of honour.
A eulogy by the statesman's daughter Meghan, one of his seven children, included a thinly veiled swipe at President Donald Trump.
"The America of John McCain has no need to be made great again, because America was always great," she said.
Crowds lined the route as the senator's final motorcade travelled to the academy in Annapolis.
Mr McCain was buried next to his classmate and friend, Admiral Chuck Larson, who reserved four plots in the idyllic cemetery for the pair and their wives before his death in 2014.
"Chuck has his wingman back now," the late admiral's widow, Sarah Larson, told CNN.
Mourners lined the route as Mr McCain's hearse made its way to his final resting place
Mr McCain's sons Jack and Don were scheduled to pay tribute to him at the Sunday ceremony, alongside retired Army General David Petraeus and Senator Lindsey Graham, a long-time friend.
President Trump - who had major personal and political differences with Mr McCain - has spent the weekend at his private golf course in Virginia, and did not attend.
Former US Senator Joseph Lieberman, a friend and colleague of Mr McCain who also gave a eulogy at Saturday's service, told CNN on Sunday: "I say goodbye and my heart will be heavy. I'll shed a tear and yet I'll thank God that I knew a man like John McCain so well."