Hoy, Philip Hindes and Jason Kenny progressed to the final of the three-man, three-lap sprint in a world record of 42.747 seconds and clocked another world record in a stunning finale, finishing in 42.600secs.
In a repeat of the final four years previously in Beijing, France's Gregory Bauge, Michael D'Almeida and Kevin Sireau had to settle for silver, finishing in 43.013.
Bronze went to Germany (43.209), with world champions Australia (43.355) fourth.
British women Victoria Pendleton and Jess Varnish had earlier been relegated from the team sprint for a takeover infringement and Britain's men's team pursuit quartet had also set a world record.
The Duke and Duchess of Cambridge and Prince Harry arrived after Pendleton and Varnish were eliminated from the competition, but were part of the capacity velodrome as an expectant crowd, including Prime Minister David Cameron, witnessed Hoy's historic achievement.
The 36-year-old from Edinburgh, competing in his fourth Games, had won one-kilometre time-trial gold in Athens in 2004 and three titles at Beijing 2008.
His Velodrome triumph in London brought him level with Sir Steve Redgrave as the Briton with most Olympic golds.
Five days later, Hoy became the most successful Briton in Olympic history with his sixth gold medal after winning the keirin in trademark fashion to send a partisan crowd into raptures.
Hoy, who also claimed 11 world titles, announced his retirement from cycling in April, 2013.