Bayern Munich salvaged a late 2-0 win at Schalke in the Bundesliga on Friday, maintaining new coach Carlo Ancelotti’s winning start.

Minutes after missing a golden opportunity, Robert Lewandowski opened the scoring in the 81st minute, finding the top left corner after being set up by a fine pass from Javi Martínez. The Poland striker then set up substitute Joshua Kimmich to seal the result in injury time, with Ancelotti’s other substitutes, Arturo Vidal and Douglas Costa, both involved in the buildup.

“We knew we had to be patient,” said Lewandowski, who took his goal tally to four from two games after scoring a hat-trick in the opening defeat of Werder Bremen. “That was a very important win.”

Schalke, who were hoping to bounce back from the opening weekend defeat at Eintracht Frankfurt, took the game to the defending champions, snapping at the visitors’ heels, winning challenges and forcing mistakes.

“It’s bitter for us,” said the Schalke coach, Markus Weinzierl, who added that he was nevertheless encouraged by his side’s performance.

Ukraine winger Yevhen Konoplyanka and French midfielder Benjamin Stambouli made their Schalke debuts, while new loan signings Nabil Bentaleb and Baba Rahman impressed for the home side. Bayern’s 19-year-old Renato Sanches, who helped Portugal win the European Championship, also made his Bundesliga debut.

Schalke had the game’s first big chance when David Alaba blocked Leon Goretzka’s header almost on the line, before Konoplyanka’s shot was deflected wide for a corner and Goretzka went close again.

Lewandowski should have put away Bayern’s first big chance minutes later, turning the ball wide after being set up by Thomas Müller.

The hosts 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 had pulled it back, all set up by a great run from Baba.

Huntelaar rattled the crossbar early in the second half, as Neuer got fingertips to the ball. Ancelotti reacted to Schalke’s growing confidence by bringing on Vidal and Costa for Xabi Alonso and Franck Ribéry, respectively.

Costa fired over in the 72nd minute before Lewandowski missed an open net from close range. The Poland striker had no time to react to Alaba’s cross and the ball ricocheted over – but just when it looked like the visitors would have to settle for a point, Lewandowski made amends, then set up Kimmich, to gather all three.