Deus ex machina
Latin for “god from the machine,” it originated in Greek theaters and was eventually translated into Latin. It came about when a mechane (a crane) would lower a person or persons playing the role of a god or gods to find a solution to a hopeless situation. This formed the phrase “god from the machine.” In modern times deus ex machina has come to describe anyone or anything that seemingly arrives from nowhere to resolve the conflict in a story.
Examples: In J.R.R. Tolkein's Lord of the Rings: The Return of the King Frodo and Sam (the ringbearers) are trapped on Mount Doom during the eruption. Eagles fly from a distance and proceed to rescue them.
Sources: