Raikkonen had pitted for a second time on lap 38, but Mercedes saw a greater overall advantage in leaving Bottas on track ahead of Vettel than trying to cover off the second Ferrari with a more conventional strategy.
Lap 26: Hamilton pits from the lead for soft tyres.
Having been fifth and sixth in the two Friday practice sessions, Mercedes looked more competitive in FP3 but both Hamilton and teammate Valtteri Bottas spun as they struggled with the car's handling.
It was a bad day for Red Bull's Max Verstappen, as the team suffered their second mechanical failure in successive races. No driver has gone on to take the championship after winning here since Michael Schumacher in 2004, a trend the British driver is in a strong position to buck.
Lap 67: Bottas hits Ricciardo as the Red Bull tries to pass the Mercedes into the first corner. Ricciardo, who had started 12th, took a whack from Marcus Ericsson in Turn 1, but was able to continue despite losing a handful of positions and dropping to 15th. The lead has changed hands six times between the two this season but this is the largest gap either has held in the 12 races thus far.
Jose Mourinho launches impassioned defence of frustrated Alexis Sanchez
All I can say is that we will try everything we can to be as successful as possible and in the end we will see'. It helps them to understand the game. "It was better than I would have expected, to be honest".
Vettel, his rival in the race to become a five-time world champion, finished second after passing Bottas five laps from the end. Behind them Verstappen got away well, moving up to fifth from seventh on the opening lap.
The rain that fell more heavily in the second phase put a premium on getting in a good early lap but Canadian Lance Stroll spun his Williams in front of him and the Australian had to abort his effort.
Hamilton even felt Bottas would have beaten him in a dry qualifying session, and admits he is unsure how hard it will be to manage his tires in the race given the difficulties he has faced so far in Budapest.
Ferrari's gamble had not paid off and worse still even on the quicker rubber could make no impact on Bottas who quickly pulled out of DRS range.
The Aussie failed to get in a good enough lap at the start of Q2, and as the rain intensified, he was unable to haul his auto into the top-10 shootout and qualified only 12th. The British driver was in serene control out front however and he won by 17sec from Vettel.