Sebastian Vettel held off Ferrari Formula 1 team-mate Kimi Raikkonen to clinch a tense Hungarian Grand Prix victory, as Lewis Hamilton handed Valtteri Bottas third and the Red Bulls collided.
Vettel, who drove most of the race with steering issues, crossed the line 0.9seconds ahead of Raikkonen to secure Ferrari's second one-two of the 2017 F1 season.
Hamilton ceded third to Bottas on the final lap as agreed after his team-mate had let him through under team orders earlier in the race to try to attack the Ferraris.
Vettel's fourth win of the season, and first since Monaco in May, extends his championship lead to 14 points over Hamilton heading into the summer break.
Vettel and Raikkonen stayed one-two after the start, with the Red Bulls of Daniel Ricciardo and Max Verstappen swarming the Mercedes of Bottas and Hamilton.
Verstappen got around the outside of Hamilton with a bold move into Turn 1, but ran wide on the exit and then came under pressure from Ricciardo.
Verstappen locked up into Turn 2 and ran into Ricciardo, causing damage to the left-hand side of his team-mate's Red Bull but escaping unharmed himself.
Ricciardo, who was furious with Verstappen on the radio, dropped down the field and then spun at Turn 4, with fluid leaking from his car, forcing Jolyon Palmer off track to avoid contact.
He then pulled over to the side of the track and retired, bringing out the safety car.
The stewards deemed Verstappen to be at fault, imposing a 10s time penalty.
Vettel led comfortably from Raikkonen in the first stint but then started reporting steering concerns.
As the Mercedes started closing on the Ferraris, Raikkonen called on his team to ask Vettel, who was struggling to turn in, to cede position but the request was not accepted.
Mercedes agreed to Hamilton's similar request with Bottas, on the proviso that the positions were swapped back if Hamilton could not pass Raikkonen.
Once through, Hamilton was soon on Raikkonen's gearbox and was told he had five laps of full power to make a pass.
That deadline was extended but Hamilton could not get through and gave up the chase in the closing laps.
Verstappen had run long before his pitstop and led for a spell before the penalty dropped him back.
He rapidly closed on the lead quartet in the final stages and began to attack Bottas, raising doubts over whether Mercedes would be able to swap its cars back.
But Hamilton lifted off on the final lap, allowing Bottas through then slotting back in just ahead of Verstappen, as Raikkonen shadowed Vettel to the flag in front.
Fernando Alonso scored McLaren-Honda's best finish of the season with sixth, setting fastest lap right at the end, while Stoffel Vandoorne gave it two cars in the points with 10th.
Toro Rosso's Carlos Sainz Jr was seventh after a controversial early wheel-banging battle with Alonso, just ahead of Force India's Sergio Perez and Esteban Ocon.
Grosjean, who made contact with Nico Hulkenberg and Marcus Ericsson at the start, was forced to pull over and retire his Haas when a wheelnut was cross-threaded at his pitstop.
The unwell Felipe Massa's stand-in Paul di Resta spent his first F1 race since 2013 battling with the Saubers before Williams told him to retire late on due to an oil leak.
After dropping back in his first-corner clash with Grosjean, Hulkenberg looked set to regain ground by running long only for a problem in his pitstop to drop him back.
He was then forced off the road while trying to pass Kevin Magnussen, who was given a 5s penalty for the move, for 11th and retired just as he had caught back up to Magnussen and Daniil Kvyat.
RESULTS - 70 LAPS:
|5||Max Verstappen||Red Bull/Renault||13.276s|
|7||Carlos Sainz Jr.||Toro Rosso/Renault||1 Lap|
|8||Sergio Perez||Force India/Mercedes||1 Lap|
|9||Esteban Ocon||Force India/Mercedes||1 Lap|
|10||Stoffel Vandoorne||McLaren/Honda||1 Lap|
|11||Daniil Kvyat||Toro Rosso/Renault||1 Lap|
|12||Jolyon Palmer||Renault||1 Lap|
|13||Kevin Magnussen||Haas/Ferrari||1 Lap|
|14||Lance Stroll||Williams/Mercedes||1 Lap|
|15||Pascal Wehrlein||Sauber/Ferrari||2 Laps|
|16||Marcus Ericsson||Sauber/Ferrari||2 Laps|
|-||Paul Di Resta||Williams/Mercedes||Oil leak|
|-||Daniel Ricciardo||Red Bull/Renault||Collision|
|9||Carlos Sainz Jr.||35|