Save the Day:

If you save the day, you do something to ensure success or to solve a serious problem.

It looked like we were going to lose the game, but Ronaldo saved the day by kicking two late goals.

Then a guy rides in on a white horse and saves the day by killing the bad guys and rescuing the girl.