Deus ex machina has a bad reputation. And not without reason. This highly contrived way of solving an unsolvable problem in a work of fiction is one of the hallmarks of sloppy writing; it’s a clear sign that an author has “written themselves into a corner.” Still, as a plot device, deus ex machina isn’t 100% bad. In fact, it can be an effective tool in your writer’s kit if you know how to use it correctly.

First of all, if you’re gonna criticize it, make sure you know how to pronounce it. It’s not DOOS ex mah-SHEEN-ah. It’s DAY-us ex MAH-kin-ah.

Deus ex machina” is a Latin term meaning “god from the machine.” The “machine” in question was part of the Greek and Roman theatrical tradition: a crane-like device above the scenery that allowed an actor playing the “deus,” or god, to hover above, and even descend to, the stage below, where he would proceed to resolve the drama through his divine intervention.

This sort of plot twist wasn’t considered clumsy at the time; the concept divine intervention was part of the Greek and Roman cultural framework. But today, using a deus ex machina to tie up the dangling plot threads of a story — be it a novel, movie, TV show, or creative non-fiction — is frowned upon. Even so, you can (and sometimes should) incorporate it in your work, provided you follow basic three rules.

1. Your reader must be familiar with both the “deus” and the “machina”

When you use a deus ex machina, it’s crucial that you take steps to make sure your target audience isn’t confused by any aspect of the plot device. It’s important that they understand and have experience with the miraculous phenomenon (the “deus”), as well as the means by which it’s hidden and revealed within the plot (the “machina”), given their social background and the cultural context of your story.

In other words, if you’re going to write a deus ex machina, the all-powerful force and the manner in which it resolves the plot must not baffle your reader.

The 1988 movie Working Girl offers a very ’80s example of this. Its deus is a powerful businessman who can effortlessly cut through office politics, defeat the villain, and bring about a happy ending, all with a simple command (something that seems positively miraculous to the main character). Within the worldview of the movie and its viewers at the time it was released, he is an identifiable character type known to have god-like powers. And he can easily be hidden within the typical late-20th-century power structure of the corporate world, until the moment he chooses to make us aware of his might.

The ending of the 1897 science fiction novel The War of the Worlds contains another example of a deus ex machina that requires that its readers have specific scientific knowledge prior to picking up the book. In the climax, the invincible alien invaders succumb not to the desperate war of survival waged by the humans, but to Earth’s invisible but deadly microbes. Because contemporary readers are familiar with how microscopic pathogens work, this surprise twist doesn’t come completely from left field.

A reader from an era before the discovery of bacteria and viruses, however, would never accept such an ending. Neither a god’s intervention nor a human hero felled the monsters — they just up and dropped dead? Unlikely!

2. The deus ex machina must already exist in the world of the story

Your deus ex machina can take any form you want — it can be magic, a natural disaster, an improbable coincidence — but it must be established as “real” and “possible” within the context of the story before it appears. Ensuring that it’s both “real” and “possible” comes down to two factors: worldbuilding and foreshadowing.

When the Tyrannosaurus rex bursts into the scene and kills the raptors at the end of the original Jurassic Park movie, it’s an acceptable deus ex machina. This is because the T. rex has been established as part of the plot through foreshadowing. Likewise, the fact that a dinosaur — an extinct creature that shouldn’t be bursting in anywhere — saves the day is also acceptable because of worldbuilding that set up the return of dinosaurs; in the world of Jurassic Park, dinosaurs are creatures that currently exist.

Long-dead lizards are one thing, but can the deus ex machina in a modern story be an actual god, like in ancient Greece? Sure, as long as the world of the story features supernatural or religious elements that are established from the get-go. If you’re writing a Christian romance novel, for example, it’s fine to have God intervene via a miracle that resolves the plot, because such interventions are accepted in the world of the story.

But remember, you must clearly introduce your religious or supernatural elements early in the narrative — don’t assume your reader shares your cultural worldview. And you’ve got to make their sudden appearance logical within the world of your story. Just as Jesus descending to smite the raptors at the end of Jurassic Park would have been beyond bizarre, a T. rex appearing to unite a Christian couple just won’t work.

T. rex lovers

However, the delightfully absurd image this suggests brings us to Rule #3.

3. All bets are off in comedy

Well, almost. As long as you’re writing an absurdist comedy, and follow Rule #1 and Rule #2, you can get away with just about anything.

One of the best examples of a deus ex machina ending in a work of comedy can be found in the 1975 film Monty Python and the Holy Grail.

The unexpected appearance of modern police officers, who break up a battle taking place in mythical Arthurian England, is a skillful deus ex machina because the filmmakers took pains to introduce the existence of the police in a few brief scenes prior to the climax, while peppering the action throughout the movie with similarly irrational moments. Thus, the deus ex machina seems like nothing more than a nonsensical but not unreasonable culmination of a series of ludicrous plot points.

Using the three rules, I incorporated a deus ex machina ending into my novel, The Cure for Summer Boredom. You can check it out here.

Katherine Luck is the author of the novels The Cure for Summer Boredom and In Retrospect. Her latest book, False Memoir, combines the high stakes of a gritty psychological thriller with the guilty pleasure of a sensational true crime tell-all. You can read more of her work, including the “Dead Writers and Candy” series, at

Katherine Luck books

2 thoughts on “How to write a deus ex machina ending

Comments are closed.