John McCain has been laid to rest at the US Naval Academy after five days of events remembering the life of the maverick senator.

A horse-drawn carriage led a procession of mourners from the academy’s chapel to its cemetery following a private service.

The senator’s widow, Cindy, and his children were among those who walked behind the carriage. Joining them were family and friends as well as members of McCain’s Class of 1958, military leaders and academy midshipmen.

McCainFamily members, including Cindy McCain, follow the horse-drawn carriage (Susan Walsh/AP)

About 4pm, a flyover of military aircraft honoured the Navy pilot who was shot down over Vietnam and held more than five years as a prisoner of war.

The burial was private as was the wish of Mr McCain, the Arizona Republican and 2008 presidential nominee who died on August 25 from brain cancer aged 81.

One scheduled speaker at the service, Senator Lindsey Graham, said before the service that he would tell the audience that “nobody loved a soldier more than John McCain, that I bear witness to his commitment to have their back, travel where they go, never let them be forgotten”.

Also expected to pay tribute were David Petraeus, a retired general and former CIA director, and Mr McCain’s son Jack.

McCainPeople watch as the funeral procession passes (Susan Walsh/AP)

As the hearse carrying Mr McCain passed through a gate and into the academy, there was loud applause from the several hundred people lining the street outside on a hot and muggy summer day.

Many held their hands over their hearts and waved American flags. Some shouted “God bless you”.

People in the crowd held signs that read “Senator John McCain Thanks For Serving! Godspeed” and “Rest In Peace Maverick.”

For his final resting place, Mr McCain picked the historic site overlooking the Severn River, not Arlington National Cemetery, where his father and grandfather, both admirals, were buried.

Years ago Chuck Larson, an admiral himself and an ally throughout Mr McCain’s life, reserved four plots at the cemetery — two for Mr McCain and himself, and two for their wives, now widows.

Mr Larson died in 2014, and Mr McCain wrote in a recent memoir that he wanted to be buried next to his friend, “near where it began”.

Among the pallbearers on a list provided by Mr McCain’s office were Frank Gamboa, his academy roommate; Defence Secretary Jim Mattis; and two men who were POWs with Mr McCain in Vietnam, John Fer and Everett Alvarez Jr.

Tributes to Mr McCain began on Wednesday in Arizona and continued for the remainder of the week.

Former presidents attend the memorial service for John McCainFormer presidents attend the memorial service for John McCain (Pablo Martinez Monsivais/AP)

On Saturday, speeches by his daughter Meghan and two former presidents — Republican George W Bush and Democrat Barack Obama — remembered Mr McCain as a patriot who could bridge painful rivalries.

While their remarks made clear their admiration for him, they also represented a repudiation of President Donald Trump’s brand of tough-talking, divisive politics. Mr Trump and McCain were at odds during the 2016 campaign and for much of Mr Trump’s presidency.

“There’s a lesson to be learned this week about John McCain,” said Mr Graham.

Meghan McCain speaks at a memorial service for her father John McCain Meghan McCain speaks at a memorial service for her father (Pablo Martinez Monsivais/AP)

“No. 1, Americans appreciate military service. … If you work hard and do your homework and know what you’re talking about, people will listen to you. That if you pick big causes bigger than yourself, you’ll be remembered,” he told Fox News Sunday.

“He tried to drain the swamp before it was cool, that you can fight hard and still be respected. If you forgive, people appreciate it, and if you admit to mistakes, you look good as a stronger man.

“That’s the formula, John McCain. This was a civics lesson for anybody who wanted to listen. Why do we remember this man? Because of the way he conducted his public life.”