BUDAPEST, Hungary — Mercedes driver Lewis Hamilton won the Hungarian Grand Prix for a record fifth time on Sunday to take the championship lead from teammate Nico Rosberg, who finished second.

Red Bull's Daniel Ricciardo was third, followed by Ferrari's Sebastian Vettel and Max Verstappen of Red Bull.

Hamilton now has five F1 victories this season for 192 points, with Rosberg on 186 and Ricciardo third with 115, one point clear of Ferrari's Kimi Raikkonen.

Hamilton completed the 70 laps of the Hungarian circuit in 1 hour, 40 minutes and 30.115 seconds, at an average speed of 183.059 kph (113.7 mph). He beat Rosberg by 1.977 seconds.

Ricciardo was a further 27 seconds behind, less than a second ahead of Vettel.

Rosberg won the first four races this year, while Hamilton has won five of the last six. Verstappen is the only non-Mercedes driver to win a race in 2016.

Hamilton started second on the grid, with Rosberg in pole position, but was able to pass the German on the first turn.

"The start was everything," said Hamilton, who before this victory was tied with Michael Schumacher for most wins at the Hungaroring, with four. "I got a good start. I had one of the Red Bulls on the inside so I was pressured quite a lot into turn one. What a day!"

"Once I've gone into the lead, I just manage my tires, my car and manage the gap and react only when I needed to," the two-time defending champion said.

Ricciardo also briefly passed Rosberg at the start but while the Mercedes driver was able to pull back ahead in that duel he was never able to pass Hamilton.

"I was happy to take Daniel in turn two and from then I was trying to put all the pressure possible on Lewis," Rosberg said. "I lost the win there."

Despite losing the championship lead midway through the season, Rosberg, who Friday signed a contract extension with Mercedes through 2018, was confident about the remaining races.

"It's very close. Up till now it was a good battle with Lewis. It's still a long, long way to go," Rosberg said. "Now I move my focus to Hockenheim because it's my home race and I really look forward to racing there. I love the track."

Hamilton's lead over Rosberg was rarely more than two seconds, while Rosberg's lead over Ricciardo grew to 8.1 seconds by the end of lap 18. The Australian, however, was able to close that gap to 2.8 seconds by lap 30.

Mercedes noticed the shrinking lead and told Hamilton to "push," or they would have Rosberg change tires ahead of him. Hamilton answered that he was "driving as best as I can" but seemed to respond to the request and Ricciardo never really challenged again.

"I think the first part of the race we were quite competitive," Ricciardo said. "But in the end it looked like the Mercedes had a bit more in their back pocket and were able to improve the pace as the race went on."

The race seemed uneventful after lively practice sessions — including a crash by Hamilton — and lengthy qualifying on Saturday, interrupted several times by heavy rainfall and numerous crashes along with controversy over Rosberg's alleged failure to slow under yellow flags.

McLaren's Jenson Button was the only driver who did not finish the race, pulling out after 60 laps with smoke coming out of the car.

Button was also the first casualty of the new rules by FIA, motorsport's governing body, forcing drivers to enter the pit lane for repairs — or withdraw from the race — if they are warned over the radio of any malfunctions.

Button started eighth but soon developed hydraulic problems. He was instructed to avoid shifting gears, which meant he should have returned to the pit lane, but the car seemed to recover and he was told to stay out on the track. Stewards reviewed the radio messages and gave Button a drive-through penalty, to the British driver's clear dismay.

In the constructors' championship, Mercedes leads with 378 points, Ferrari has 224 and Red Bull 223.

The next race is the German Grand Prix on July 31, followed by the traditional summer break and then the Belgian Grand Prix on Aug. 28.

___

Karel Janicek contributed to this report.