Deus ex machina
An ending or rescue that arrives from outside the story instead of growing out of it: a sudden power, a lucky arrival, a coincidence that solves the problem the characters could not. Latin for "god from the machine", after the crane that lowered gods onto the stage in Greek theatre.
In practice
The Latin means "god from the machine". It now names any ending, rescue or solution that arrives from outside the story's own logic: help nobody set up, a power nobody mentioned, a coincidence that happens to fix the one problem the protagonist could not. The audience feels it as a cheat because the protagonist's choices stop mattering at the moment they matter most.
On the page it rarely looks like a god. It is the cavalry that turns up unannounced, the stranger who happens to hold the key, the inheritance that pays the debt, the villain who dies of something unrelated, or the storm that sinks the enemy fleet in the last ten pages. Readers of a script spot it fast, and it is one of the most common notes in coverage of a third act.
The fix is usually a plant, not a cut. Set the rescue up early enough that it pays off instead of arriving, tie it to something the protagonist did, or make it cost them. The Pixar story artist Emma Coats put the rule of thumb in one line: coincidences that get characters into trouble are great; coincidences that get them out of it are cheating.
Fixing one in a scene
INT. HARBOR OFFICE - DAY
NINA (30s) signs the last page of a salvage contract. The old harbormaster, BEALE, slides a brass card printed with a radio channel across the desk.
BEALE
You ever get in real trouble out there, channel sixteen. I owe your father that much.
Nina pockets the card without looking at it.
EXT. OPEN SEA - NIGHT
The hull is splitting. Soaked, Nina digs the brass card out of her jacket and twists the radio dial to sixteen.
NINA
Beale. You said you owed him.
Static. Then, on the horizon, the harbor tug's searchlight swings toward her.
Without the first scene, the tug is a deus ex machina: help that arrives because the story needs it. With it, the rescue is a payoff. It was planted in a scene that seemed to be about something else, and Nina has to remember it and ask for it, so the ending turns on her choice.
Where the term comes from
In Greek theatre a crane called the mechane swung an actor playing a god over the stage, and the god settled whatever the mortals could not. Euripides used the device often. At the end of his Medea, she escapes in a chariot sent by the sun god Helios, and in Orestes Apollo appears to resolve a plot that has run out of road.
Aristotle objected in the Poetics: the unraveling of a plot should come out of the plot itself, not from the machine, and he named the Medea as an example of the fault. A few centuries later the Roman poet Horace gave playwrights a rule in the Ars Poetica: don't bring a god on stage unless the knot is worthy of one. Screenwriting advice has been repeating both of them ever since.
How to spot one in your draft
Take the solution to your biggest problem, usually in the climax, and ask four questions. Was it set up before the audience needed it? Did the protagonist cause it, ask for it or pay for it? Would the ending still work if the protagonist were absent from the scene? Does it arrive at the exact moment of greatest pressure, and from nowhere?
If the answers are no, no, yes and yes, you have a deus ex machina. It also hides in smaller places: the guard who looks away, the phone that suddenly has signal, the witness who walks in with the evidence. Each one is minor, but a script that solves its problems this way three or four times reads as a story the writer is rescuing rather than one the characters are living.
How to fix it
Plant it. Show the tool, the ally or the rule early, in a scene that seems to be about something else, so the payoff feels inevitable rather than convenient. This is Chekhov's gun used on purpose, and it is the most common cure.
Make it the protagonist's doing. The help arrives because they called for it, traded for it or earned it with a choice earlier in the story. If the rescue still has to come from outside, make it cost something: an alliance they hate, a secret revealed, a debt that comes due in the next scene.
Sometimes the honest fix is to let the problem win. If nothing in the story can solve it, the ending you had planned may be the wrong one, and the scene that follows the failure is often stronger than the rescue was.
When it works on purpose
Comedy and farce use it knowingly. Molière's Tartuffe ends with an officer of the king arriving to arrest the swindler and restore everything, an ending so abrupt that it plays as a joke about how only the king could untangle the mess. Parody and absurdist stories lean on the same move.
It is also not a flaw when the story has taught us the rules. A god who intervenes in a myth where gods have intervened all along is not a deus ex machina. H. G. Wells's The War of the Worlds ends with the invaders killed by bacteria, and readers still argue about it. The novel's first paragraph compares humanity to creatures scrutinized under a microscope, which makes the ending a planted irony rather than a rescue from nowhere.
Common questions
What does deus ex machina mean literally?
"God from the machine". It translates a Greek phrase for the god lowered onto the stage by a crane, the mechane, to settle the plot at the end of a play.
How do you pronounce deus ex machina?
Merriam-Webster gives DAY-us eks MAH-kih-nuh first, and lists variants for the last word, including MAK-ih-nuh and muh-SHEE-nuh. Any of them will be understood in a writers' room.
What is an example of deus ex machina?
The cavalry arriving unannounced, a sudden inheritance that pays the debt, or a storm that sinks the enemy fleet just in time. In each, something the story never set up solves the problem the characters could not.
Is deus ex machina always bad?
No. Comedy and farce use it on purpose, and some stories make the arbitrary rescue their point. It becomes a flaw when the audience was asked to care whether the characters could solve the problem themselves.
How do you fix a deus ex machina?
Plant the solution earlier so it pays off rather than appears, tie it to a choice the protagonist made, or make it cost something. Sometimes the honest fix is to let the problem win and rewrite what follows.
Is a plot twist a deus ex machina?
Not if it was planted. A twist reveals something that was true all along, and the clues are there on a second viewing. A deus ex machina adds something that was never there to solve a problem.
What is the difference between deus ex machina and Chekhov's gun?
They are opposites. Chekhov's gun is a detail set up early that must pay off later. A deus ex machina is a payoff with no setup. Planting the rescue as a Chekhov's gun is the standard cure.