Lewis Hamilton held off Max Verstappen, and survived a late collision with the Red Bull driver, to win a nail-biting Monaco Grand Prix.
The world champion was left struggling with the tyres on his Mercedes after fitting softer rubber than the Dutchman at pit stops during an early safety-car period.
Britain's Hamilton repeatedly complained that he was not going to be able to make the tyres last to the end but by careful management held on to take his fourth win of 2019.
Verstappen dropped from second on the road to fourth in the results because of a five-second penalty, promoting Ferrari's Sebastian Vettel to second and Mercedes' Valtteri Bottas to third.
Verstappen's punishment was for an unsafe release in the pits when all the leaders pitted on lap 12 as a safety car was deployed to clear up debris laid by Charles Leclerc's Ferrari.
Although Mercedes' run of consecutive victories at the start of this season continued, their sequence of one-twos is over as a result of Bottas' bad luck.
And Hamilton now holds a 17-point lead over his team-mate in the championship.
The defining moment of the race
Wearing a helmet painted in a design used by Niki Lauda, the Mercedes non-executive chairman who died on Monday, Hamilton was controlling the race, ahead of Bottas, Verstappen and Vettel, after converting his pole position into a lead a the first corner.
But the race came to life when Leclerc suffered a puncture when he spun trying to pass Nico Hulkenberg's Renault for 11th place on lap eight.
Leclerc had been making up ground after Ferrari's farcical strategic error in qualifying on Saturday meant he failed to progress beyond the first session.
The Monegasque had passed Romain Grosjean's Haas for 12th place with a brave move at Rascasse on the previous lap. He tried the same on Hulkenberg but the German left him less room.
They rounded the corner together but Leclerc's rear wheel caught the inside barrier, pitching him into a spin and puncturing the tyre.
He got going again, losing only two places, but his tyre began to deconstruct around the next lap and tore chunks out of his rear bodywork as he returned to the pits.
When the safety car was deployed, Hamilton led the leaders into the pits, as Bottas backed up Verstappen and Vettel to give Mercedes time to service both cars.
Red Bull pulled off a super-quick stop and released Verstappen into Bottas' path, and the two cars touched as the Finn was forced into the pit wall on the outside.
It gave Verstappen second place on the road, and caused Bottas a puncture that meant he had to stop again the next time around, losing a place to German Vettel. But ultimately it cost him more than it gained him - and he was given two penalty points on his licence as well as the time penalty.
Why was Hamilton struggling so much?
Hamilton's problem was that Mercedes had fitted medium tyres to his car, while Verstappen and Vettel were given hards - which Bottas was also switched to when he pitted for the second time.
It meant Hamilton had to do 66 laps on a set of mediums, when they were only projected to last 50.
It is unclear why Mercedes chose the medium, and the decision gave Hamilton a tough afternoon, spent controlling his pace and fending off Verstappen.
Passing is difficult at Monaco, but regardless it meant Hamilton could not afford to make a mistake despite fading grip, which was no easy task.
His concern was plain as he repeatedly complained over the radio that he was not going to make it and would not be able to hold Verstappen off.
At one point, he even said it was going to take a "miracle" to win it.
In the end, with about 10 laps to go, Mercedes' chief strategist James Vowles came on the radio and said: "You can make it if you trust it."
Verstappen went for it at the chicane with two laps to go, but he was too far back and locked a wheel, and they touched as Hamilton came across him.
Hamilton took to the escape road and carried on, as Verstappen complained: "He just turned in. I was trying to overtake."
That was the last drama and Hamilton hung on for the remaining two laps.
Driver of the day
What happens next?
Canada in two weeks' time. Mercedes will start as favourites, but the long straights might give Ferrari their first chance to be competitive since Baku two races ago.
What they said
Hamilton: "That was definitely the hardest race I've had but nonetheless I really was fighting with the spirit of Niki - he's been such an influence in our team and I know he will be looking down and taking his hat off. I was trying to stay focused and make him proud that it's been the goal all week and we truly miss him."
Vettel: "A tough race to manage, at Monaco something always happens, Max must have had an incredible stop, I saw them (Verstappen and Bottas) touching in the pit lane. I wanted to put some more pressure on, I just struggled with my tyres, not as badly as Lewis and Max's, but mine were just not getting hot."
Bottas: "It's obviously disappointing for me, I think the speed was there and I was feeling good in the car. It was small margins yesterday and that made today difficult. Max got me in the pitlane and left me with no room and then I was stuck behind, it was like a Sunday drive."