Atletico Madrid advanced to the Copa del Rey quarter-finals, despite suffering a 3-2 defeat against Las Palmas in the second leg at Vicente Calderon on Tuesday.
Leading 2-0 from the first leg, Atleti went in front through Antoine Griezmann early in the second half, but they were pegged back by Marko Livaja's equaliser eight minutes later.
Angel Correa then restored the hosts' three-goal cushion in the tie on 61 minutes, although they were handed a scare when Livaja levelled again in the final minute before Mateo Garcia struck the winner in stoppage time.
However, it was not enough to knock out Diego Simeone's side, who progressed to the last-eight 4-3 on aggregate.
— Atleti English (@atletienglish) January 10, 2017
After a goalless first half, Griezmann broke the deadlock four minutes into the second stanza as he played a one-two with Nicolas Gaitan before slotting home from close range.
But Livaja kept the cup-tie alive when he restored parity on 57 minutes, shaking off a challenge from Diego Godin to fire into the bottom-right corner of the net.
Los Rojiblancos responded swiftly, though, with Correa chasing down a long ball and made his way into the area before scoring between the legs of visiting keeper Raul Lizoain.
They appeared to be cruising as the clock wound down, but were caught napping by the Canary Islanders at the death as Livaja converted Mateo Garcia's cross from a few yards out, before Garcia pounced on Jonathan Viera's pass from a free-kick to lash the ball home inside the near post with virtually the final kick of the match.