Word or phrase for turning the tide against a rival in a competition in the last moments
I'm sure there's a more specific word/phrase for moments like in a soccer match when the loser team which is, say, two scores behind, scores 3 points in the last ten minutes to turn an almost certain defeat into a great victory to everyone's surprise.
PS: An alternative context can be a legal dispute or even a military battle.
Turning the tide is already idiomatic, but another common phrase is "to snatch victory from the jaws of defeat". Here, defeat is pictured as a monster threatening to eat you.
Definition of the jaws of defeat
: the position of being close to losing
// The team was able to snatch victory from the jaws of defeat by scoring in the final seconds of the game.
(source: Merriam-Webster)
An example of a single word is "comeback", but that can also be used for a career, not just something that's happening in a single game.
A comeback (or come-from-behind) is an occurrence of an athlete or sports team engaged in a competition overcoming a substantial disadvantage in points or position, particularly if this results in the disadvantaged team winning.
(source: Wikipedia)
A team that comes from behind to win has turned it around. Merriam-Webster:
transitive verb : to change for the better | turned her life around
If it happens at the last minute, it occurs in the nick of time. Cambridge Dictionary:
In the last possible moment
Indeed, these phrases have occurred together before:
They turned it around in the nick of time winning the final three games of the series to advance to the conference final. (Bleacher Report)
Fusco turned it around in the nick of time, with seven seconds left for the 3-1 championship victory and second consecutive Section II title. (Community News)
World No.1 Karolina Pliskova struggled for the second consecutive match at the 2017 US Open -- and, once again, she turned it around in the nick of time. (WTA)
But Wawrinka turned it around in the nick of time, holding for 4-4, and broke down Kohlschreiber in an eight-minute game of five deuces, eventually converting his sixth break point, 6-4. (The Sport Review)