Jupp Heynckes' men were the controlling force for most of the match and, although Leverkusen found some hope through deflected Kevin Volland goal, Bayern ended its host's 12-match unbeaten run and claim a first win at the BayArena since March 2013 despite Robert Lewandowski's absence through knee injury.
The entertaining first half was initially end-to-end, with the two sides having fairly equal shares of the ball, but Bayern gradually gained control and identified Leverkusen's main weaknesses; their susceptibility at set-pieces and Karim Bellarabi's reluctance to track back.
As such, it came as little surprise to see Bayern's opener come via a corner, with Javi Martinez slamming home after Leverkusen failed to clear its lines.
The in-form Leon Bailey went close to a stunning equaliser when he struck the crossbar nine minutes after the break and Bayern soon made the most of that, as Ribery rounded off a swift break with his first Bundesliga goal of the season.
Volland pulled one back via a deflection of Niklas Sule in the 70th minute to usher in a period of intense Leverkusen pressure, but Bayern - which introduced new signing Sandro Wagner late on - wrapped things up through James' exquisite stoppage-time free-kick to increase its lead at the top ahead of Schalke's trip to RB Leipzig on Sunday.
Bayern was the first to craft an opportunity as Arjen Robben led a break and picked out Ribery at the back post, but Bellarabi recovered to block the Frenchman's eventual effort.
A couple more chances fell to the visitor in quick succession in the 17th minute, with Bernd Leno forced to turn Arturo Vidal's effort from an acute angle around the post, before saving the Chilean's header from the resulting corner.
Leverkusen's first real chance a few moments later should have opened the scoring, but the unmarked Dominik Kohr headed wide from the left-wing corner.
And Bayern punished his profligacy in the 32nd minute – Martinez blasting in from close range after Vidal's header ricocheted into his path.
Things nearly got worse for Leverkusen a few minutes later, but Vidal nodded just wide.
Leverkusen did not appear any more of a threat initially after the break, but a moment of individual brilliance from Bailey nearly restored parity in the 55th minute.
The Jamaican winger darted into the right side of the penalty area and left Sule in knots, before chipping a left-footed effort on to the bar.
Bayern took full advantage soon after, as they caught Leverkusen on the break and Ribery – exploiting the space left by Bellarabi – strode into the left side of the area before tucking his effort into the bottom-left corner.
But luck was on Leverkusen's side 20 minutes from time, as Volland's effort from just outside the penalty area took a huge deflection off Sule and beat the helpless Sven Ulreich.
Another chance presented itself to Volland late on, as Kai Havertz fed the striker into the penalty area, but his first touch was poor and allowed Ulreich to make a vital save.
And James ended Leverkusen's fading chances in stoppage time, caressing a free-kick into the top-left corner from the edge of the area to cap off a strong individual performance.