The Bundesliga debutants were on the back foot for most of the first half but took control when Marcel Sabitzer and Timo Werner scored with headers in a four-minute spell just after the restart.
Jairo Samperio pulled one back from a penalty for Mainz but a brilliant effort from Guinea midfielder Keita, who evaded half the Mainz team before capping his run with a stylish finish, settled the match nine minutes from the end.
Yoshinoro Muto's consolation goal came too late for the hosts who had Jean-Philippe Gbamin sent off.
Leipzig are 10 points behind Bayern who suffered only their second defeat of the season, 1-0 at Hoffenheim on Tuesday.
Mainz are 15th on 29 points with only goal difference keeping them above Augsburg in the relegation playoff spot.
Read the full article on eurosport.co.uk: Leipzig edge closer to Bayern after Keita brilliance