Javi Martinez headed Bayern Munich into the knockout stages of the Champions League after Callum McGregor looked to have denied them victory in a dramatic 2-1 win over Celtic on Tuesday.
McGregor's equaliser in the 74th minute appeared set to make Bayern wait for their place in the next round until Martinez leapt to meet a David Alaba cross just three minutes later.
Kingsley Coman had given Bayern a first-half lead after a disastrous defensive lapse involving Dedryck Boyata and Craig Gordon allowed him to fire into an empty net.
Three points for Bayern, combined with Group B leaders Paris Saint-Germain's victory over Anderlecht, sees the Bundesliga champions assured of a top-two finish, while Brendan Rodgers' men are eliminated.
The result was perhaps harsh on Celtic, with little to choose between the sides on the night.
A typically passionate Celtic Park crowd should have been celebrating a goal after five minutes, but Stuart Armstrong appeared surprised that a perfectly weighted cross from James Forrest on the break arrived at his feet.
The ball bounced wide off Armstrong from barely four yards out but Celtic continued to look bright and Moussa Dembele dragged past the right-hand post after boldly running at the Bayern defence.
Things were not quite clicking for Bayern early on and, while the cross that led to Coman prodding wide after 18 minutes was played a touch too far in front of him, the France winger should have done better when he got his feet in a tangle in the centre of the box moments later.
But Coman redeemed himself with the help of some questionable Celtic defending.
A long ball from the boot of Sven Ulreich was allowed to bounce by Boyata, prompting goalkeeper Gordon to desperately rush off his line into no man's land.
Coman collected and kept his cool to pick a spot in the open net and, while Bayern shot stopper Ulreich will be credited with a rare assist, it was Boyata's passive defending that made the visitors' opener possible.
Bayern had Alaba to thank for preserving their lead on the half-hour mark, when the Austria international's last-ditch tackle denied Dembele a simple tap-in.
Armstrong then forced Ulreich into a diving save with a powerful drive early in the second half, before McGregor sent the home fans into raptures with a well-worked goal.
A delightful throughball from Forrest carved open the Bayern defence and found McGregor, who tucked the ball under Ulreich for the leveller.
But that joy was short lived, as Martinez - who sustained a nasty cut to his eye in the process - climbed above Nir Bitton to nod beyond Gordon for Bayern's crucial winner, silencing the previously boisterous Parkhead faithful.
Key Opta Stats:
- Celtic have won just one of their last 13 Champions League matches (W1 D3 L9), conceding 36 goals in the process.
- Bayern have never lost to Scottish opposition in the Champions League (six games - W4 D2 L0).
- No goalkeeper assisted a goal in the four seasons of Champions League football between 2013-14 and 2016-17, but Sven Ulreich became the second to do it in 2017-18 after Chelsea's Thibaut Courtois on matchday one.
- Kingsley Coman has had a hand in two goals in his last two Champions League games for Bayern Munich having previously gone 13 matches without registering a single goal or assist.
- Javi Martinez netted his first Champions League goal in what was his 38th appearance in the competition for Bayern.