Aleix Espargaro won the British MotoGP on the final lap from world champion Francesco Bagnaia at Silverstone on Sunday.
Brad Binder of KTM completed the podium on the return of MotoGP after its mid-season break.
Baignaia extended his lead in the riders' standings to 41 points after his closest challenger Marco Bezzecchi crashed out.
"It was crazy, I felt super good with the bike," said Espargaro who continued the race's tradition of producing a different winner every year since 2013.
Rain began to splatter the circuit late on to add spice to a tense finish with Espargaro timing his decisive move on Bagnaia to perfection.
"The last lap was dramatic!" said the Spaniard who prevailed despite starting from only 12th on the grid.
Despite missing out on his fifth win of the season Bagnaia was all smiles, especially after finishing pointless down in 14th in Saturday's sprint.
"It was tricky. I tried to push but I was on the limit.
"Finishing second is a great result," the Ducati factory rider said.
He leads the 2023 world championship on 214 points from Jorge Martin (173) and Bezzecchi (167).
The race began in dry and sunny conditions in stark contrast to Saturday's deluge.
Pole-sitter Bezzecchi was pipped to turn one by KTM's Jack Miller, with Bagnaia in hot pursuit.
'Pecco' was up to second at the end of the first lap and then surged past Miller to lead.
Bezzecchi, racing for Valentino Rossi's VR46 Ducati-satellite team, emerged as Bagnaia's main rival - Miller suddenly plummeting down the pack and out of contention.
Sprint winner Alex Marquez was forced to retire early with a damaged bike.
Joan Mir, the 2020 champion, crashed and Bezzecchi then tumbled out with 15 laps to go.
That left Bagnaia with a slender lead over Espargaro, who had quietly picked his way through the pack.
Bagnaia had a clutch of challengers ready to pounce over the final two laps and it was Espargaro who hit the front late on to claim his second career MotoGP win.
nr/ea