Yoshinori Muto had given them the lead just before half-time, but a penalty from Ruslan Gurbanov and another goal for Sergei Zenjov put the hosts on course themselves for a first win in European group stage football.
However Mainz’s substitutes came to the rescue, with Jhon Córdoba and Levin Öztunali scoring to send them on the long trip home with all three points.
Four changes for Mainz
Gabala, who made it through all four rounds of qualifying to make the group stages, made sweeping changes for their weekend league game against FK Zira, a 2-0 win, however they started with the same eleven that started their opening Group C game two weeks ago, a 3-1 defeat to RSC Anderlecht.
Mainz begun their first-ever European group stage campaign with a 1-1 draw against AS Saint-Étienne, with a goal from captain Niko Bungert, who was on the bench here.
Martin Schmidt made four changes from the late loss to Bayer Leverkusen in the Bundesliga at the weekend, with Christian Clemens, Alexander Hack, José Rodriguez and Muto all recalled, with Córdoba and Öztunali joining Giulio Donati on the bench, and Leon Balogun out injured.
Muto makes most of Mainz’s control
Mainz controlled possession in the opening stages, with their front three all looking in rhythm, but it took until the twentieth minute for a first shot on goal, although Pablo De Blasis fired over with his first time shot from Yunus Malli’s ball.
The hosts though then had an excellent chance to take the lead. Gurbanov whipped the ball in from the right, with a looping header from Ricardinho striking the post. Zenjov should have scored from the rebound, but instead he managed to fire over.
Mainz continued to probe away. Malli had a poor attempt go wide, with Christian Clemens shooting over and Gaëtan Bussmann heading a Malli corner into the palms of Dmytro Bezotosniy.
They would lead before the break though. Bussmann set up Muto, with an excellent strike from the Japanese striker going in despite Bezotosniy getting a hand on the ball.
Gabala seize the initiative
Mainz started the second half brightly, with De Blasis having a chance to score within seconds of the restart from a Muto ball, and then Malli had a chance saved by Bezotosniy.
Gabala were offering little, but then they were handed a way back into the game, A poorly-judged headed back pass from Stefan Bell was jumped on by Filip Ozobic, with Jonas Lössl in desperation bringing him down for the penalty. The Mainz keeper was beaten straight down the middle by Gurbanov from the spot.
The momentum was with the home side, and before long they were 2-1 up. Poor lacklustre defending opened the way for Bagaliy Dabo to set up Zenjov. He chased the ball down and shot at the first possible opportunities, beating Lössl to send it into the far corner.
Substitutions come good for Schmidt
Schmidt threw on Öztunali and Córdoba in an attempt to turn things around. It was an instant success. A Mainz corner was headed on by Bussmann, with Córdoba connecting to poke home a goal less than 60 seconds after coming on.
Öztunali needed a little longer to make his impact, but ten minutes later he would put Mainz back front. Fabian Frey played a long pass through to him, he fought his way past Ricardinho and squeezed it past Bezotosniy.
Mainz’s defensive frailties wouldn’t come back to haunt them in the final stages. They probably should have extended their lead, with Córdoba hitting the bar via Bezotosniy. Dabo came closest to an equaliser for the Azerbaijanis, shooting wide.
So Mainz clung on for their first victory in a group stage match, and topped the group ahead of the evening game between Saint-Étienne and Anderlecht, with the Belgians visiting the Opel Arena in three weeks’ time.