Reigning champion Bagnaia finished runner-up on Sunday and stretched his overall lead to 41 points after a nail-biting four-way battle in tricky conditions, with South African Brad Binder third for KTM.
Spaniard Espargaro denied Bagnaia his fifth grand prix win of the season by 0.215 seconds, with the top four separated by just 0.750, while Australian Jack Miller finished eighth on his KTM.
Marco Bezzecchi, Bagnaia’s closest title rival before the race, crashed out at Stowe while chasing his compatriot, and slipped to third overall, with Pramac Ducati’s Spaniard Jorge Martin moving up to second.
The win was Espargaro’s first since Argentina last year and, impressively, came from 12th on the grid.
“It was crazy. From lap one, even if I started 12th, I felt immediately super-good with the bike,” the 34-year-old veteran said.
“It was one of those days that you feel invincible.”
Espargaro was up to second by lap six, helped by teammate Maverick Vinales and Miller clashing and running wide ahead of him.
Bagnaia had taken the lead on the second lap from fourth on the grid, but the front of the field bunched up when the rain came seven laps from the end, with plenty of jostling for second place.
Espargaro passed Bagnaia with half a lap remaining and made the move stick.
“At that time, my plan was to pass him (Bagnaia) and try to go away,” Espargaro said.
“But when it started to rain I said ‘OK, stay quiet behind Pecco, it’s better that he open the track’.
“And then on the last lap I had something more so I tried to overtake him.
“But the last laps were quite dramatic, a lot of riders coming from behind, very slippery. I was quite scared in the last part.”
Bagnaia said he was happy to bank solid points and a sixth GP podium of the campaign.
“It was tricky ... we chose the soft front tyre but it was a bit on the limit,” the Italian said.
“It was very easy with our bike to lose the front.
“Then when it started to rain I didn’t know how much to push, where was the limit.
“To finish second today is a great result.”
Portugal’s Miguel Oliveira was fourth for the RNF Aprilia team, with Vinales fifth and Martin sixth.
AAP