Bagnaia pips championship leader Martin to win Catalan Grand Prix with Marquez third
Marquez repeated his heroics from Saturday's sprint when he finished an astonishing second from 14th, keeping polesitter Aleix Espargaro at bay until the chequered flag and finishing five-hundredths of a second ahead to take third.
Bagnaia had crashed on the final lap of the sprint when he was leading but Sunday's victory - his third of the season - was redemption for the Italian who is now 39 points behind Martin.
"Honestly, I was angry about yesterday knowing I had the potential to win," Bagnaia said.
"When I saw riders struggling with the front today I started to push more."
Just as in Saturday's sprint, Bagnaia and Pedro Acosta moved up to first and second at the start while sprint winner Espargaro was pushed down to fifth in his final home race.
Martin also had a blistering start to go from seventh on the grid to third, with Red Bull KTM's Brad Binder slotting in behind him.
Acosta attempted to overtake Bagnaia when he could but it was Martin who had the pace and he quietly took second place from the GasGas Tech3 rider before overtaking the factory Ducati rider when he saw a tiny gap on the fourth lap.
But Acosta, on soft tyres, was in no mood to sit back when he saw Bagnaia slowing him down, overtaking the Ducati to give Martin chase as the duo quickly peeled away from Bagnaia.
ROOKIE MISTAKE
Martin had longer-lasting medium tyres and could afford to bide his time while behind him Acosta looked for every opportunity to move ahead, but the eager rookie made a second mistake in as many races when he crashed with 14 laps left.
Bagnaia continued to reel in Martin and, with six laps to go, he dived in at turn five - the same corner he had crashed at while leading Saturday's sprint - to seize the lead from the Pramac Racing rider.
Behind them, Marquez had managed to move up to fourth and he quickly pulled up on Espargaro's rear tyre in the fight for the final podium spot, eventually passing his Spanish compatriot with four laps to go.
But unlike his last lap heroics at Le Mans earlier this month, Marquez was too far behind to give Bagnaia and Martin any cause for worry.
"I took the soft rear tyre and I knew it was risky but it was the only solution to attack from the beginning," Marquez said.
"I didn't make a good start but I made it step by step, I knew the race was long. When I overtook Aleix, I was able to defend the position."
With three straight podiums, Marquez is now third in the championship, two points behind Bagnaia.