Yamaha rider Razgatlioglu completed a hat-trick of wins at the Indonesian venue, but in that situation Bautista only needed to finish third in order to seal the crown ahead of next weekend's Phillip Island finale.
Second place behind the outgoing champion was enough for Bautista to take an insurmountable 66-point advantage over Razgatlioglu, giving the Spaniard his first world championship since he won the 2006 125cc crown.
For Ducati, an 11-year wait for a WSBK riders' champion since Carlos Checa's 2011 success came to an end, just a week on from its historic MotoGP title triumph in Valencia with Francesco Bagnaia.
"Today before [the Superpole race] I started to feel pressure," said Bautista. "It was difficult to manage that situation. I knew I had more races, but it was the first match point I had in my hands, not depending on other riders.
"There was more pressure on me, so I just tried to not make any mistakes. I'm so happy, because even with the pressure of the championship, we were able to do a good job and win the championship."
Story of the race
With track temperatures nearing 70 degrees Celsius on the freshly-relaid asphalt, Kawasaki man Jonathan Rea was the early leader from the Yamahas of Razgatlioglu and Andrea Locatelli, as Bautista settled into fourth place after running wide on a slightly nervy opening lap.
It appeared as if Bautista would have to deal with the threat of newly-crowned independents' champion Axel Bassani as well, but the works Ducati man held firm before going back on the attack against Locatelli.
A forceful pass on Locatelli at the long Turn 15-16 right-hander on lap 4 of 21 put Bautista back in a title-winning position, as Razgatlioglu hassled his 2021 title adversary Rea for the lead of the race.
On lap 6, Razgatllioglu was able to get the move done under braking into the Turn 10 right-hander, and on the very next lap, Rea made a small error at Turn 9 and allowed Bautista through into second.
Despite the title being on the line, Bautista appeared in no mood to settle for second as Razgatlioglu was unable to make good his escape, with the Ducati rider closing in as the race reached mid-distance.
Bautista was able to dive ahead of Razgatlioglu approaching Turn 1 at the start of lap 14, but Razgatlioglu stuck close to the tail of the Ducati and wrested back the lead as they went into Turn 10.
Just moments later, Bautista replied with another move at Turn 15-16, but like Razgatlioglu some laps earlier he wasn't able to build an advantage up front, allowing the Turkish rider to repass for the lead at Turn 10 on lap 16.
Once back in the lead, Razgatlioglu immediately set a new fastest lap and was finally able to build a one-second lead, finally scoring his 14th victory of the season by a margin of 1.2 seconds.
Bautista then had to spend the final few laps protecting second from a resurgent Rea, who briefly dropped behind Bassani before recovering to third.
Bassani lost another spot in the closing stages to Locatelli, who completed his strongest weekend since Assen in April.
Scott Redding struck an important blow in the fight to avoid the bottom spot in the manufacturers' standings for BMW as he beat the sole works Honda of Xavi Vierge to sixth place.
Garrett Gerloff (GRT Yamaha), Alex Lowes (Kawasaki) and Michael Ruben Rinaldi (Ducati) completed the top 10.
Kohta Nozane (GRT) and Kyle Smith (Puccetti Kawasaki) both dropped out of the running with crashes, while Philipp Oettl (Go Eleven Ducati) was a non-starter after being diagnosed with a suspected concussion.
Mandalika World Superbike - Race 2 results:
|10||21||Michael Ruben Rinaldi||Ducati||0||19.698|
|12||60||Michael van der Mark||BMW||0||22.218|
|View full results|