Eric Maxim Choupo-Moting scored a 92nd-minute penalty to earn Schalke a 4-3 win after they had surrendered a two-goal lead at home to 10-man Sporting Lisbon on Tuesday night.
A grandstand second half which saw two Adrien Silva goals, the first a penalty, bring Sporting level from 3-1 down had looked set to deny Roberto Di Matteo victory in his first Champions League game in charge of the Royal Blues.
But Choupo-Moting saved his side's blushes at the death after Jonathan Silva had been penalised for handball to send the Germans second in Group G.
Schalke had earlier recovered from conceding the opener to Nani to draw level through Chinedu Obasi before half-time, Mauricio seeing red in the build-up to the equaliser.
Goals early in the second half from Klaas-Jan Huntelaar and Benedikt Howedes set the hosts on what looked set to be a routine win, but they did things the hard way before finally squeezing over the line.
This was Di Matteo's first Champions League match since guiding Chelsea to European glory against Bayern Munich in 2012 and he would not have been happy with how his side started.
The visitors settled the quicker, with Islam Slimani firing over the top from inside the area before Nani gave them a 15th-minute lead.
Joao Mario's short corner from the right was played to the on-loan Manchester United man, who rifled a low effort into the net with his right foot.
Julian Draxler saw his shot blocked and Obasi had a header saved by Rui Patricio as Schalke looked for a way back into the contest before they were gifted one by their opponents.
Booked only 14 minutes earlier, Mauricio clattered into Marco Hoger in an aerial duel and was shown a second yellow.
And from the resulting free-kick, swung in from the right by Dennis Aogo, Obasi sent a header low into the right corner.
The Nigerian forward almost added a second a minute before half-time, but this time headed wide from another Aogo delivery.
The hosts needed just six minutes of the second half to go in front as Huntelaar shot home from inside the area, Obasi this time with the assist.
The momentum was firmly with Schalke now and nine minutes later Howedes headed in Kaan Ayhan's free-kick from close range.
It should have been plain sailing from then on for the 11 men, but they inexplicably let Sporting back into the contest.
Adrien Silva blasted home a 63rd-minute penalty after a foul by Ayhan on Andre Carrillo and, 15 minutes later, the same player headed a right-wing cross low into the net to put Sporting on course for an unlikely win.
But they could not see out the match as Jonathan Silva's block of Huntelaar's header was ruled a handball and Choupo-Moting held his nerve to convert the winning penalty.