deus ex machina
Concise Oxford English Dictionary © 2008 Oxford University Press:
deus ex machina /ˌdeɪʊs ɛks ˈmakɪnə, ˌdiːəs ɛks məˈʃiːnə/
▶noun an unexpected power or event saving a seemingly hopeless situation, especially as a narrative device in a play or novel.
– origin C17: mod. L., translation of Gk theos ek mēkhanēs, ‘god from the machinery’ (with ref. to the actors representing gods suspended above the stage in ancient Greek theatre, who brought about the denouement of the play by their intervention).
'deus ex machina' also found in these Oxford entries:

