Bagnaia could have sealed the crown in the sprint but despite starting a row in front of Martin he failed to sparkle.
Instead it was the Spaniard who fronted up taking the lead on his Ducati-Primac with just over half the 13 lap race completed to record a crucial win and re-energise his title hopes in Sunday's MotoGP.
Martin -- winning his ninth sprint race of the campaign -- will be crowned champion for sure if he wins and Bagnaia finishes outside the top five.
"I took a big gamble in racing on a soft rear tyre," said Martin.
"It was not easy starting from sixth spot and trying to pass my rivals.
"I was having problems on the left hand turns but I got into a rhythm.
"I watched as Brad Binder moved away but I gave everything and went really hard.
"This shows that tomorrow I can win on proper tyres!"'Be aggressive'
However, Martin admitted his task was a tough one to deny Bagnaia the title, with the Italian like in the sprint race due to start a row in front.
"Well it is better a 14 point deficit than the 21 it was this morning!" he said.
"But for sure it is complicated and all I can do is win the race and then see where Bagnaia finishes."
Bagnaia may have won six MotoGPs to Martin's four this season but the 'Martinator' has had the upper hand in the sprint races -- and Saturday's was no exception despite an indifferent performance in morning qualifying.
Bagnaia had a wonderful start dropping to fifth from second with 12 of 13 laps remaining while Martin moved into third.
The 25-year-old Spaniard had over a second lead on the Italian by the fourth lap.
The 2021 champion Fabio Quartararo, who had soared from 15th to sixth, came to grief with nine laps remaining as he tried to pass Bagnaia -- the Frenchman slapping his hands together in frustration.
Binder passed pole sitter Maverick Vinales for the lead with just over half of the race run but if Bagnaia's Ducati team were looking for a surge from the Italian they were to be disappointed.
The 26-year-old could not make any impression on the front quartet.
Binder's lead did not last long as to the roars of the home crowd Martin passed both Vinales and the South African to hit the front and was never challenged from there on in.
Binder finished second and was more than happy with his performance.
"I pushed the boundaries to their limits out there," he said.
"My aim was to be aggressive and I just put my head down and went for it."
Meanwhile Bagnaia -- who secured the title last year on the final day of the season -- looked relaxed as he sat with his team and smiling gave a thumbs up sign.