Bastianini wins British MotoGP sprint as Bagnaia crashes out
Bastianini was followed in second by Jorge Martin (Ducati-Pramac), who now stands just one point behind Bagnaia in the overall standings ahead of Sunday's main race.
Pole-sitter Aleix Espargaro (Aprilia) finished third.
Martin was quickly on to Espargaro's tail at the start of the race, overtaking on lap one and appearing to take control.
Bastianini struggled to stay with him for the first couple of laps but slowly reeled him in before sliding past to take the lead which he held until the end for his first win of any kind since taking the Malaysian MotoGP last November.
"I am very happy," said Bastianini.
"It was a very good fight with Jorge, we were pushing the limit. The lap time was too crazy, all the sprint has been crazy.
"It's my first victory of the year, I'm so happy at one of my favourite tracks, Silverstone. Fantastic."
Martin's second place gave him nine points and tightens the race at the top of the standings but a win would have put him above Bagnaia.
"Right from the start, I took the lead but Enea was much stronger today," he said after the race.
Six-time world champion Marc Marquez, who went into the sprint third in the title race, was running a comfortable fourth when he crashed on the penultimate lap -- only the second time he has failed to score points in a sprint this season.
He subsequently dropped to fourth in the title race behind Bastianini who goes up to third.
An eventful start saw Franco Morbidelli rear-ending Marco Bezzecchi's Ducati, both Italians sliding off the track, debris cascading from their bikes.
All three will be ready to go again in Sunday's MotoGP for which Espargaro, Bagnaia and Bastianini will start on the front row with Martin just behind them.
Espargaro surprised Bagnaia with a brilliant late lap in qualifying earlier on Saturday to snatch pole position.
The 35-year-old Spaniard, who is retiring at the end of the year, reclaimed the lap record for Silverstone where he won 12 months ago with a time of 1 minute 57.309 seconds, which was 0.208sec ahead of Bagnaia.
It is the seventh pole of Espargaro's career and his second this season, following his success in Barcelona where he went on to win the sprint before coming fourth in the grand prix.
"I'm happy with my performance today especially in the qualifying," said Espargaro after the sprint.
"In the sprint I did all I could. I was at the limit, It was a nice race and hopefully tomorrow we can push even more."