Ducati man Bautista looked on course for his second win of the weekend in Portugal after passing Rea for the lead on lap 14 of 21, but came under renewed attack from his Kawasaki rider in the closing stages.
Rea failed to make a move stick at either of Estoril's most obvious passing points, the Turn 1 right-hander and the Turn 6 double left-hander, but launched an ambitious assault on Bautista into the downhill right-hander of Turn 7.
That move didn't come off either, as Bautista nosed back in front, but it set Rea up to dive up the inside at the tight Turn 9-10 complex and hang on through the final couple of turns for his fifth win of the season by just 0.194 seconds.
It narrows the gap between the two in the championship to 17 points, with Rea also having won earlier in the day in the Superpole race.
The opening half of the race was characterised by a battle between Rea and reigning champion Toprak Razgatlioglu, who led off the line until being repassed by his 2021 title rival into Turn 6 on the first lap.
Yamaha rider Razgatlioglu briefly made it back ahead at the start of lap 7, but was again demoted by Rea two laps later, and on lap 11 by Bautista.
Razgatlioglu initially stuck close to the two leaders but faded in the closing laps, finally finishing four seconds down in third place - extending his winless run at the start of his title defence.
Alex Lowes matched his best finish of the year on the second Kawasaki in fourth, running in the leading group early on but losing touch with the pack when he ran wide at the first corner on lap 15.
Andrea Locatelli (Yamaha) barely clung to fifth ahead of Iker Lecuona, whose Honda bizarrely shed its front mudguard on the warm-up lap, but seemingly not impacting the Spaniard's pace.
Seventh went to Axel Bassani on the privateer Motocorsa Ducati ahead of Michael Ruben Rinaldi's factory V4 R, while Xavi Vierge (Honda) and last-minute GoEleven Ducati replacement Xavi Fores completed the top 10.
Scott Redding was BMW's top representative in 11th place as his difficult start to the season continued.
Puccetti Kawasaki's Lucas Mahias was a non-starter after a hand injury sustained in a crash in the Superpole race.
Estoril WSBK - Race 2 results:
|8||21||Michael Ruben Rinaldi||Ducati||16.082|
|View full results|