It follows the victory parade in Manchester on Monday when thousands of supporters lined the streets to cheer on the victorious athletes.
Team GB won 67 medals in Rio, two more than they gained at London 2012, while the Paralympians won 147 medals - 27 more than four years ago.
Medallists also attended a reception at Buckingham Palace.
About 6,000 people were expected at the "Heroes Return" event in central London which began at 13:00 BST.
Several of the athletes addressed the crowd from the stage, paying tribute to the support they had received.
Paralympian Richard Whitehead MBE said the event was "amazing" and called London "a special place for sport".
Swimmer Adam Peaty, who won Team GB's first gold medal and broke his own world record at Rio, said seeing the number of spectators in Trafalgar Square meant "so much" to him.
London mayor Sadiq Khan said the athletes had "inspired millions of people".
"I feel privileged and humbled to be here as a fan," he said.
The event ended with the athletes dancing on stage during a performance by The Vamps, after which confetti was released in the square.
Various members of the Royal Family - including the Duke and Duchess of Cambridge and Prince Harry - joined the Queen to meet medallists at the Buckingham Palace reception.
You can read more stories about inspiring sporting stars on our Pinterest board
Britain's Olympic and Paralympic stars have been honoured with a celebration in London's Trafalgar Square.