The four-time champion seized the lead at the start and fought back after losing the initiative during two safety car periods to register his second win at Silverstone and the 51st of his career.
Vettel's win wrecked Hamilton's hopes of taking a record fifth win in succession and a record sixth overall, but the Englishman – who was last after a collision with Kimi Raikkonen on the opening lap – produced a heroic drive to finish second for Mercedes.
His team-mate Valtteri Bottas, on older tyres, led the closing laps, but was unable to resist Vettel or his Ferrari teammate Kimi Raikkonen, who finished third. Bottas was fourth.
It was Ferrari’s first win in Britain since 2011.
Daniel Ricciardo came home fifth for Red Bull ahead of Nico Hulkenberg of Renault, Esteban Ocon of Force India, Fernando Alonso of McLaren and Kevin Magnussen of Haas. Pierre Gasly was 10th for Toro Rosso.
"The safety car spiced it up," said Vettel, wearing supporting tapes on his stiff neck. "I had the advantage of the tyres, but it was not easy to find a way through."
Raikkonen apologised for his first lap brush with Hamilton. "It was my mistake," he said. "I deserved the penalty, but I kept fighting."