Deus ex machina can literally be translated as 'God from the machine’, and is a plot device where there is an out of nowhere solution to a conflict, that is unearned by the characters who benefit from it.
It originated from ancient Greek theatre, where the character playing God would literally be carried on to the stage with a crane in order to solve a crisis by divine intervention.
Paranormal television shows such as Charmed and Supernatural have become infamous for using this method of rescuing the characters or finding out vital information that would be impossible to obtain without the help of a friendly angel or two. It has also long been used for comedic effect in shows such as Batman, where he always had the right item to save himself (‘shark-repellent bat spray’ for instance!)
Many consider it to be lazy storytelling when the writer has written themselves into a corner and can't think of a clever or logical way of bailing the characters out. A proper set up earlier in the movie can avoid this and make the surprise pay off in a much more satisfactory way, but often it is just used for a quick fix to enable the story to have a happy ending or tie up loose ends neatly.
Here are some examples of films that used deus ex machina to solve their inescapable problems.
10. Hazel Is Saved From The Cat By The Farmer’s Daughter - Watership Down
Watership Down was first released on film in 1978 as an adaption to the 1972 Richard Adams novel about a colony of rabbits and contains many upsetting and disturbing scenes considering it was an animated film meant for children (General Woundwort is an especially nightmare-inducing creature!)
One of the more distressing scenes is set up when some of the rabbits infiltrate a farm in order to try and free some of the female doe rabbits to join them. The farm cat, Tab, tries to creep up at them and one of the rabbits (Hazel) taunts her into jumping at them before they escape.
Later in the film when the rabbits return to release the farm’s guard dog with the hope of using it to attack another colony of rabbits, Tab manages to catch Hazel and uses the same taunt on him, asking ‘Can you run? I think not!’. She is about to kill him, when suddenly the farmer’s daughter Lucy intervenes by ordering Tab to back away. She then takes Hazel into the country to a location which is coincidentally near his warren.
The chapter in the book which leads up to this event is even titled Dea ex Machina (Dea meaning ‘goddess’), showing that the author was aware of the impact of this plot choice.