Eric Maxim Choupo-Moting came off the bench to fire Paris St Germain into the Champions League semi-finals as Atalanta's fairytale came to a heartbreaking and dramatic conclusion.
The Serie A side were literally within seconds from a famous victory at the Estadio da Luz in Lisbon when Marquinhos bundled home an equaliser to set the stage for Choupo-Moting to win it 2-1 in a dramatic finish.
In the process, they got team-mate Neymar out of jail after he had earlier passed up a series of glorious opportunities.
The French side, who have so often fluffed their lines at the business end of the competition in recent years, will face either RB Leipzig or Atletico Madrid in the last four.
PSG should have been ahead with less than three minutes gone when, seconds after Alejandro Gomez had forced a save from Keylor Navas, Neymar ran clear of a flat-footed Atalanta defence from halfway to go one-on-one with keeper Marco Sportiello, only to stab his shot horribly wide.
Navas was called upon again to claw away wing-back Hans Hateboer's 11th-minute header with the Italians giving as good as they got in a very open start to the game.
Neymar continued to look the man most likely to hurt Atalanta as the Ligue 1 side struggled for fluency, but it was Gian Piero Gasperini's men who took a 26th-minute lead when the ball fell kindly for Mario Pasalic to sweep it imperiously past the helpless Navas.
Neymar came within inches of a swift equaliser when, after cheekily pushing the ball through Pasalic's legs, he made space for himself before firing agonisingly wide from the edge of the penalty area.
Neymar's touch in front of goal continued to elude him as Sportiello comfortably fielded his curling 35th-minute free-kick before the Brazilian sliced woefully wide as the half-time whistle approached.
PSG upped the tempo on their return to stretch their opponents, who picked up a rash of yellow cards as they worked to keep them out, with Marten De Roon's piledriver, which flew wide from distance, and Berat Djimsiti's snapshot rare moments of relief.
Kylian Mbappe's arrival as a substitute on the hour gave PSG fresh impetus, and he forced a vital 74th-minute save from Sportiello after being played in down the left by fellow newcomer Leandro Paredes before being denied by Jose Palomino's timely block.
However, it was Marquinhos who forced home a 90th-minute equaliser with the help of a touch from Mattia Caldara's boot to set the stage for a grandstand finish.
The clock had ticked into the third of five minutes of stoppage time when Neymar and Mbappe combined superbly to allow Choupo-Moting to fire home the winner and deal Atalanta the cruellest of blows.