Former US presidents George W Bush and Barack Obama led tributes to John McCain in a ceremony for the veteran Republican that echoed his criticisms of Donald Trump.
Mr Obama spoke of the long talks he and Mr McCain would have privately in the Oval Office and Mr Bush said one of the great gifts in his life was becoming friends with his former White House rival.
The funeral was the last public event in Washington, part of McCain's five-day, cross-country funeral procession, culminating at the majestic Washington National Cathedral.
In a not-so-veiled nod to Mr Trump, Mr Obama said: "So much of our politics, our public life, our public discourse can seem small and mean and petty, tracking in bombast and insult and phony controversies and manufactured outrage."
President Trump, who clashed with Mr McCain on several occasions, was told to stay away from all events during the five-day, cross-country funeral procession.
Despite Mr Trump missing out on an invite, Mr McCain's daughter Meghan made sure he was part of the memorial in another way, levelling pointed criticism at the president in her eulogy.
"We gather here to mourn the passing of American greatness, the real thing, not cheap rhetoric from men who will never come near the sacrifice he gave so willingly, nor the opportunistic appropriation of those who lived lives of comfort and privilege while he suffered and served," she said.
Mr Bush, a Republican, and Mr Obama, a Democrat, both spoke during the service at Mr McCain's request.
Mr Bush recalled a champion for the "forgotten people" at home and abroad whose legacy will serve as a reminder of the power of America as more than a physical place but a "carrier of human aspirations."
"John's voice will always come as a whisper over our shoulder, we are better than this, America is better than this," he said.
Before the service, Mr McCain’s procession passed the Vietnam Veterans Memorial, where his wife, Cindy, laid a wreath. Mr McCain was a prisoner of war in Vietnam.
The Arizona senator is to be buried on Sunday in a private ceremony at his alma mater, the US Naval Academy in Annapolis, Maryland. He died of brain cancer on August 25 at the age of 81.
Mr McCain’s coffin arrived at the capital on Friday morning as his family watched from the steps of the White House. It then took centre stage as invited guests gathered in the vast Rotunda to remember him.
“It is only right that today, near the end of his long journey, John lies here, in this great hall, under the mighty dome, like other American heroes before him,” said Senate majority leader Mitch McConnell.
House speaker Paul Ryan called Mr McCain “one of the bravest souls our nation has produced”.
Mr McCain, a former Navy aviator, really did “talk like a sailor”, Mr Ryan said, drawing smiles from the crowd.
“But you see, with John, it wasn’t feigned disagreement. The man didn’t feign anything. He just relished the fight.”
Vice-president Mike Pence said he did not always agree with Mr McCain, but the late senator’s support for limited government, tax reform and the military “surely left our nation more prosperous and more secure”.
Mr McCain “served his country honourably,” Mr Pence said, adding that Mr Trump “respected his service to the country”.