McLaren top of the constructors' standings in a race that finished with a virtual safety car after a penultimate lap collision between Ferrari's Carlos Sainz and Red Bull's Sergio Perez.
Ferrari's pole-sitter Charles Leclerc, who was overtaken by Piastri on the 20th of 51 laps and then battled nose-to-tail before his tyres faded, came second with George Russell inheriting third for Mercedes after the Sainz-Perez collision.
Red Bull's Formula One leader Max Verstappen finished fifth, just behind his closest title rival Lando Norris, who started 15th for McLaren and ended up fourth with a bonus point for fastest lap.
Triple champion Verstappen's lead over Norris, who reeled in a 15 second gap and passed the Dutch driver on lap 49 thanks to his fresher tyres, was cut from 62 points to 59.
McLaren are now 20 points clear of Red Bull in the standings with seven rounds remaining.
"That was probably the most stressful afternoon in my life," said Piastri, after soaking up relentless pressure from Leclerc to take his second career win.
"It definitely goes down as one of the better races of my career."
The top two had duelled for lap after lap, with the Ferrari driver trying in vain to use the DRS drag reduction to get past Piastri until he faded and fell into the clutches of Perez and Sainz.
Fernando Alonso was sixth for Aston Martin with Williams benefiting from the late crash to see Alex Albon finish seventh with Argentine rookie Franco Colapinto following him home in eighth.
Seven times world champion Lewis Hamilton was ninth for Mercedes, after starting in the pit lane, and British rookie Oliver Bearman collected the final point for Haas as a stand-in for suspended Kevin Magnussen.
Bearman has now scored points for two different teams in his two races after making his race debut with Ferrari as a stand-in for appendicitis-stricken Sainz in March.
Perez tried and failed to pass Leclerc for second place on the penultimate lap and then found himself fourth as Sainz seized the opportunity to go past.
As the Spaniard and Mexican battled for third at turn two, the cars collided and went into the wall.
"What happened there?," exclaimed Sainz, with Perez asking the same thing in more colourful language.