pull it out

Intermedio alto (B2) informal

To win or succeed just when it looked like you were going to lose.

"They were losing 3–1 with ten minutes to go, but somehow they pulled it out."