Schalke, which was hoping to bounce back from its opening-weekend defeat at Eintracht Frankfurt, had taken the game to the defending champion, snapping at the visitors' heels, winning challenges and forcing mistakes.
But the home side was better and might have gone ahead in the 38th, when Alaba and Manuel Neuer—back at his old club—could only scramble the ball away from the lurking Klaas Jan Huntelaar after Konoplyanka pulled it back thanks to a great run from Baba.
Huntelaar rattled the crossbar early in the second half, when Neuer got a fingertip to the ball.
Ancelotti reacted to Schalke's growing confidence by bringing on Vidal and Costa for Xabi Alonso and Franck Ribery, respectively.
Costa fired over in the 72nd before Lewandowski missed the open net. The Poland striker had no time to react to Alaba's cross and the ball ricocheted over.
Just when it looked like the visitors would have to settle for a point, Lewandowski struck then set up Kimmich to gather all three.