Madrid, who are looking to become the first team to lift the European Cup in three successive seasons since Bayern won between 1974-76, trailed to a Joshua Kimmich goal before Marcelo and Marco Asensio hit back.
Bayern suffered an early blow when Arjen Robben was forced off injured after only eight minutes, Thiago Alcantara coming on in his place.
But Bayern took the lead just before the half-hour mark, with question marks once again over the goalkeeping of Keylor Navas. Right-back Kimmich cut into the box from the wing and fired powerfully past Navas, who had gambled on Kimmich going for the cross rather than the shot.
Shortly after the home side suffered a second injury blow, this time Jerome Boateng having to be replaced by Niklas Sule.
Madrid had offered next to nothing throughout the first half, and then two minutes before the break they were level. Daniel Carvajal headed the ball across the box and it found Marcelo on the edge of the 18-yard box, and his first-time shot across Sven Ulreich found the bottom corner.
The goal kicked Bayern back into life, with first Robert Lewandowski and then Thomas Muller failing to convert close-range headers before the half-time whistle went.
The second half started evenly, but in the 57th minute Madrid completed the turnaround. Rafinha gave the ball away just inside the Madrid half as Asensio made an interception, and the break was on. Asensio fed Lucas Vazquez, who then played the return ball to Asensio and the striker expertly lifted a shot past the onrushing Ulreich.
Ribery almost brought Bayern level on two occasions straight after the goal, but Navas was equal to his efforts.
Madrid then lost a player to injury themselves as Carvajal had to be replaced by Karim Benzema.
Cristiano Ronaldo thought he had scored a fine third on the half volley in the 71st minute, but the goal was correctly chalked off after he brought the ball down with his arm. Benzema then saw a snap shot kept out by Ulreich.
Lewandowski should have levelled two minutes from time, but he could only prod wide when played through.
Bayern couldn't find a leveller, and know they must score at least twice at the Bernabeu on Tuesday to stand a chance of reaching the final for the first time since 2012-13.
KINDLY DROP A COMMENT BELOW