Every writer, movie buff, theatre lover, and game connoisseur knows the term: deus ex machina; 'God from a machine'. The term (pronounced as 'Day-oos eks MAH-kee-nah') is a calque from the Hellenic ἀπὸ μηχανῆς θεός (apò mēkhanês theós), which has roughly the same meaning. The term has evolved into a plot device whereby a seemingly unsolvable problem is suddenly and abruptly resolved by the contrived and unexpected intervention of some new event, character, ability or object. Depending on how it is done, it can be intended to move the story forward when the writer has stuffed up and sees no other way out, to surprise the audience, to bring the tale to a happy ending, or as a comedic device.

The term was coined in Hellenic tragedy, where a machine was (and still is) used to bring actors playing Gods onto the stage. The machine could be either a crane (mechane) used to lower actors from above or a riser that brought actors up through a trapdoor. The idea was introduced by Aeschylus and was used often to resolve the conflict and conclude the drama. Although the device is associated most with Hellenic tragedy, it also appeared in comedies.

Aeschylus used the device in his 'Eumenides', but it was with Euripides that it became an established stage machine. More than half of Euripides' extant tragedies employ a deus ex machina in their resolution, and some critics claim that Euripides, not Aeschylus, invented it.

In Aristophanes' play 'Thesmophoriazusae', the playwright parodies Euripides' frequent use of the crane by making Euripides himself a character in the play and bringing him on stage by way of the mechane. Aristotle was the first to use deus ex machina as a term to describe the technique as a device to resolve the plot of tragedies. Antiphanes believed that the use of the deus ex machina was a sign that the playwright was unable to properly manage the complications of their plot:

"When they don't know what to say, and have completely given up on the play, just like a finger they lift the machine, and the spectators are satisfied. Here is none of this for us."
Aristotle also wasn't a fan and he criticized the device in his Poetics:
"As in the structure of the plot, so too in the portraiture of character, the poet should always aim either at the necessary or the probable. Thus a person of a given character should speak or act in a given way, by the rule either of necessity or of probability; just as this event should follow that by necessary or probable sequence. It is therefore evident that the unraveling of the plot, no less than the complication, must arise out of the plot itself, it must not be brought about by the Deus ex Machina- as in the Medea, or in the return of the Greeks in the Iliad. The Deus ex Machina should be employed only for events external to the drama- for antecedent or subsequent events, which lie beyond the range of human knowledge, and which require to be reported or foretold; for to the gods we ascribe the power of seeing all things. Within the action there must be nothing irrational. If the irrational cannot be excluded, it should be outside the scope of the tragedy. Such is the irrational element the Oedipus of Sophocles."

Despite that, the effect of the device on Hellenic audiences was attested as a direct and immediate emotional response. Audiences would have feeling of wonder and astonishment at the appearance of the gods and often adds to the moral effect of the drama. Even in modern plays, books, and movies, the deus ex machina can have this effect. How about the Hulk showing up near the end of The Avengers to punch that alien battleship/whale on the nose? Or the Eagles showing up at the end of the Lord of the Rings trilogy to carry our near-dead heroes home? I, for one, felt extreme elation and excitement at both. When used too much, or too obviously, the deus ex machina can be a cheap trick, but when done well, it can be quite brilliant.