%% This list of examples has been alphabetized. Please add your example in the proper place. Thanks!

%% Image replaced per Image Pickin' thread: http://tvtropes.org/pmwiki/posts.php?discussion=1321642353075040200
%% Please do not change or remove without starting a new thread.
[[quoteright:304:[[ComicStrip/TomTheDancingBug http://static.tvtropes.org/pmwiki/pub/images/godman_2061.jpg]]]]

->''"Coincidences to get characters into trouble are great; coincidences to get them out of it are cheating."''
-->-- '''Emma Coats'''

A Deus ex Machina ([[UsefuNotes/LatinPronunciationGuide pron]]: Day-oos eks MAH-kee-nah) is when some new event, character, ability, or object solves a seemingly unsolvable problem in a sudden, unexpected way. It's often used as the solution to what is called "writing yourself into a corner," where the problem is so extreme that nothing in the established setting suggests that there is a logical way for the characters to escape. If a bomb is about to go off, someone finds a convenient bomb-proof bunker in easy reach. If a protagonist [[LiteralCliffHanger falls off a cliff]], a [[GiantRobotHandsSaveLives flying robot will suddenly appear to catch them]]. A MillionToOneChance of something occurring is accomplished by a bystander who [[AchievementsInIgnorance didn't know what they were doing]].

The term is Latin for "god out of the machine" and originates in [[OlderThanFeudalism ancient Greek theater]].[[note]]the original classical Greek "theos ek mekhanikos" became "deus ex machina" through Latin translations of Greek literary criticism in the Renaissance[[/note]] It referred to scenes in which a crane (''machine'') was used to lower actors or statues playing a god or gods (''deus'') onto the stage to set things right, often near the end of the play. In its most literal interpretation, this is when a godlike figure or power, with all the convenient power that comes with that, arrives to solve the problem. A DivineIntervention need not always be a Deus ex Machina or the sole way this trope plays out however.

Note that there are a number of requirements for a sudden plot development to be a Deus ex Machina:
# Deus ex Machina are ''solutions'' to a problem. They are never [[DiabolusExMachina unexpected developments that make things worse]], nor [[TheEndingChangesEverything sudden twists that only change the understanding of a story]].
# Deus ex Machina are ''sudden or unexpected''. This means that even if they are [[ChekhovsGun featured, referenced or set-up earlier in the story]], they do not change the course of nor appear as a natural or a viable solution to the plotline they eventually "solve".
# Deus ex Machina are used to resolve a situation portrayed as ''unsolvable or hopeless''. If the problem could be solved with a bit of [[IdiotBall common sense]] or other type of simple intervention, the solution is not a Deus ex Machina no matter how unexpected it may seem.
# Deus ex Machina are ''external'' to the characters and their choices throughout the story. The solution comes from a character with [[SmallRoleBigImpact small or non-existent influence on the plot until that point]] or random chance from nature or [[LaserGuidedKarma karma]].

The concept eventually came back into vogue during the early years of the film industry thanks to UsefulNotes/TheHaysCode. Villains, and anyone else who didn't toe the moral line, were absolutely not allowed to get away with their crimes. But, more often than not EvilIsCool. [[GettingCrapPastTheRadar The solution]] was to let the bad guy be awesome for the duration of the movie, then [[DroppedABridgeOnHim drop a bridge on them]] in the last five minutes.

Remember, even the notorious Deus ex Machina [[TropesAreTools can be pulled off]]. Sudden resolutions are perfectly capable of leading to satisfying conclusions - see the entire "[[RuleOfIndex Rule Of X]]" series of tropes: RuleOfCool, RuleOfCute, RuleOfEmpathy, RuleOfFun, RuleOfFunny, RuleOfRomantic, RuleOfScary, RuleOfSexy (for those ever-so-fun {{Deus Sex Machina}}s), RuleOfSymbolism, and ''especially'' RuleOfDrama. Apparent Deus ex Machina also happen plenty in [[TruthInTelevision real life]], given reality is far more complex and random than most fictionalized versions of it. Not to mention that a Deus ex Machina short of the climax is a ChekhovsGun; if the saving force complicates the story afterwards, it's the introduction of a new element.

On top of that, the Deus ex Machina is often seen to take away from the plot and characters by forcing everything to fit. If the characters are prepared to accept the unwinnable scenario and all its consequences before the Deus ex Machina, [[LampshadeHanging even acknowledge how lucky they were it showed up]], or it is only accomplished through a HeroicSacrifice, it can take the sting out of its use.

Compare to the ResetButton, NonProtagonistResolver, DiabolusExMachina, CoincidentalBroadcast, YouDidntAsk, EurekaMoment and SuspiciouslySpecificSermon. Not to be confused with the tropes DeusEstMachina, DeusExitMachina or AveMachina. Nor the works ''VideoGame/DeusEx'', ''VideoGame/DeusExInvisibleWar'', ''VideoGame/DeusExHumanRevolution'', ''Manga/DeusExMachina'', ''Film/ExMachina'' or ''Comicbook/ExMachina''.

''Also'', please make sure an example meets '''the criteria''' before submitting. This is not a place to [[Administrivia/ComplainingAboutShowsYouDontLike Complain About Plot Twists You Don't Like]].
!!Examples (Warning: Ending Spoilers)
* DeusExMachina/AnimeAndManga
* DeusExMachina/ComicBooks
* DeusExMachina/{{Literature}}
* [[DeusExMachina/LiveActionFilms Films — Live-Action]]
* DeusExMachina/LiveActionTV
* DeusExMachina/VideoGames
* DeusExMachina/WesternAnimation


* In the third commercial of the four-part Pepsi ad Advertising/TheChase, Music/MichaelJackson gets cornered by a group of paparazzi twice. [[spoiler:But when they get to where he is, he's seemingly disappeared despite there being no obvious escape routes.]] It's strongly implied he was using [[PortalPicture Portal Pictures]] to get away, but there's no obvious signs of magic use.

[[folder:Fan Works]]
* In ''[[http://rugratonline.free.fr/rrfan35.html The Great Pokemon Fight]]'', [[WesternAnimation/{{Rugrats}} Tommy]] is mortally wounded by [[Franchise/{{Digimon}} Greymon]] during a heated battle to save the Poke-Digital World... And just as Greymon tries to finish off Tommy, he, along with his army, then just disappeared. Like, poof, bye bye. Heck, the story even says that they just disappeared for no reason. No one even questions this as they were too busy on the dying Tommy. Then he dies, and suddenly, [[Franchise/{{Pokemon}} Mew]] comes out of nowhere and revives him. In total, there's ''two'' Deus ex Machinas in the span of a minute.
* ''Fanfic/ACrownOfStars'': Deliberately invoked. After the events of canon and the preceding fic, Shinji and Asuka were physically burned-out and emotionally ''wrecked''. This story's author wanted to try to give them a happy end, and he thought that [[http://forums.sufficientvelocity.com/posts/2293239/ it would be ironical that it would take actual divine intervention to get them to fricking talk to each other]]. So that in the first chapter a GodEmperor called Daniel appeared in front of Shinji and Asuka and offered to help them. It is more justified than other examples since Daniel serves as a plot device to start the story, rather ending it, and although he can help them, he can not automatically fix all of their troubles or changing the past, and the story focuses on Shinji and Asuka and their struggles to recover from their traumas and repair their relationship. And when the main external conflict begins, the main characters are cut off him, so that he can not bail them out.
* Specifically averted and its absence discussed by characters in the ''VideoGame/HeroesOfTheStorm'' fanfic ''FanFic/HeroesOfTheDesk''. Raynor points out that "This Blizzard ain't gonna be around to write some-last-ditch save in this time."
* In ''Fanfic/InThisWorldAndTheNext'', [[Literature/HarryPotter Harry and Hermione]] are sentenced to the [[FateWorseThanDeath Dementor's Kiss]] for killing RonTheDeathEater. Instead, the Dementor ''[[MadeOfExplodium explodes]]'' and releases their life force, allowing them to [[PeggySue go back in time]]. A bit more Justified than other examples, serving as a plot device to ''start'' the story, rather than the more common use in ending it.
* In the season 4 finale of JakeEnglishsMysteriousTheaterOfScientificRomanceFromTheYear3000, after being rescued Zeus declares all the other plot threads to be resolved.
* ''Fanfic/KnowledgeIsPower'': There's not really any other way to describe Harry and Hermione being sent into the past by the ghosts of James and Lily when [[RocksFallEveryoneDies a ceiling falls on them]].
* ''Fanfic/MyBravePonyStarfleetMagic'':
** The Uniforce. A force of good only unicorns with golden horns can summon to amplify their magic by shouting that they believe. It is never explained what it really is, why only golden horned unicorns can use it and how the Grand Ruler discovered it, but it is the main attack to kill all {{Big Bad}}s.
** Mystic Light, the finishing move of [[spoiler: The Grand Celestial Ruler]].
* Chillingly done in the Pokémon fic Fanfic/NoAntidote. [[spoiler: After realizing a poisoned trainer is completely an EmptyShell, a ghost Pokémon, under orders from Giratina, takes control. The motives claim to be for the benefit of the "Starter" Pokémon that unquestionably follow their leader but...]]
--> [[spoiler: ''Ghost Controlled Trainer'']]: This is the most fun we've had in decades!
* [[https://www.fimfiction.net/story/159974/pony-age-catalyst Pony Age: Catalyst]]: The Spirit of Justice who comes out of nowhere to save Twilight and Lyra from the Sloth Demon.
* In ''Fanfic/TealovesSteamyAdventure'', the cast face a seemingly hopeless fight against a giant, mobile pear tree. Then, Fluttershy appears from nowhere (the narration just states that she was hiding behind a cart the entire time) and [[SummonBiggerFish summons a flock of fruit bats]] to take out the tree.
* [[http://archiveofourown.org/works/4403816?view_adult=true This fic]]'s version of [[Literature/HeraldsOfValdemar Valdemar]] has a variant of the trope; the 'Herald Ex Machina'. It is an accepted and expected event in Valdemaran plays for the protagonist to be saved at some timely moment (and have his/her heroism validated) by a Companion arriving and Choosing them to be a Herald. (That's because the same thing has happened to so many of Valdemar's historical figures.) For example, their version of ''Theatre/MyFairLady'' is about the same as ours, except that the ending also involves Eliza becoming a Herald; in this particular example, the 'Herald Ex Machina' doesn't resolve the plot so much as provide a handily built-in AndTheAdventureContinues.
* Happens a bunch of times in Fanfic/TwilightSparklesAwesomeAdventure:
** The new lead guard [[MemeticMutation takes an arrow to the knee]] before he can shoot Twilight. This is in a setting where guns are the weapon of choice and no character is ever shown to have a bow.
** At one point Twilight notices a hatch in the ground with a ladder in it ''inside a broom closet'' which helps her avoid a [[SpaceIsAnOcean space shark.]]
** [[spoiler: Slenderman appears out of nowhere to save Rainbow Dash from the gay snake.]]
** [[spoiler: ADMIRAL Awesome comes BackFromTheDead to save the heroes at the end of the Last Part.]]
* ''Deus Ex Rannoch'', a minor ''Franchise/MassEffect'' fic where the Refusal ending is overwritten by a [[spoiler:hidden geth/quarian empire big enough to defeat the Reapers]].
* Episode 75 of ''Fanfic/SonicXDarkChaos'' has a big one. Maledict has [[TheBadGuyWins lured the heroes into his trap and takes the entire galaxy hostage with the Galaxy Crusher in exchange for the Chaos Emeralds]], leaving the heroes in a literally hopeless situation. Suddenly, a gigantic Angel fleet led by Jesus Christ himself suddenly shuts down Maledict's trap and ambushes his fleet.
* The ending of ''Fanfic/TheStoryToEndAllStories''. {{Lampshade|Hanging}}d by Mike and the Bots.
* In ''[[https://www.fanfiction.net/s/8830812/1/Harry-s-Happy-Christmas Harry's Happy Christmas]]'' Santa Claus gives Harry a repaired wand, the Sword of Gryffindor, Voldemort (in doll form) and all of the [[SoulJar Horcruxes]] for Christmas.

[[folder:Films -- Animation]]
* It would take a while - no, maybe an entire subpage - to name the Deus ex Machinas in just about every Franchise/{{Barbie}} movie.
* The Disney film ''Disney/TheBlackCauldron''. While the cauldron is the first artifact and/or character introduced, the way it qualifies is how it takes out [[spoiler:The Horned King]]. While it was explained that a living person entering the cauldron of his or her own free will would seal its powers, it is not explained why it kills the guy and destroys the castle. It's implied that it's just that evil, but that's a rather [[HandWave flimsy explanation]]. It is also highly anticlimactic, because the [[spoiler: King]] doesn't get to DO anything, despite being hinted as being a powerful sorcerer. Another is supplied by the witches, who [[spoiler: revive the person that jumped into the cauldron]]. And why is it that the witches have this cauldron in the first place and the heroes practically fall on top of apparently the only society that knows where they are?
* A literal case in Disney's ''Disney/TheHunchbackOfNotreDame'': The BigBad spends the movie on a reign of terror that he proclaims to be for a higher cause, sings a VillainSong that's an inverted confession of sins, and assaults a cathedral. When he's swinging a sword and raving about how He shall cast down the wicked, the gargoyle under his feet roars at him and breaks off.
* A semi-literal example is the WelcomeToTheRealWorld scene in ''WesternAnimation/TheLEGOMovie'', in which Emmett dives into the void to retrieve the Piece of Resistance and falls out of the model into the real world, where he sees a vision of the child playing LEGO... and his [[StopHavingFunGuys rather less fun]] father. He eventually manages to persuade the kid to give him the Piece and put him back into the story, with him zooming out of the portal [[HomageShot like Neo at the end of]] ''Film/TheMatrix''.
* An example in ''Disney/MulanII'', when it is employed in the original style as Mushu climbs into an idol of the Unity Dragon and makes supposedly divine pronouncements (punctuated with a bit of fire-breathing) that neatly resolve what has become a very tangled situation.
* The end of the ''WesternAnimation/TheSecretOfNimh'' film just ''screams'' Deus Ex Machina. Supposedly, the "stone" that does [[MacGuffin something... powerful]] manages to respond to Mrs. Brisby's... emotion and then pulls the cinderblock out - with no loss of life (or mud, which had been flooding the house). Auntie Shrew likely survived because she fell into a PlotHole when the mud started flooding the house.
* PlayedForLaughs in ''WesternAnimation/TheSimpsonsMovie'', where Maggie shows up to defeat the villain completely out of nowhere.
* Towards the end of ''WesternAnimation/SouthParkBiggerLongerAndUncut'', Canadian comedians Terrance and Phillip are gunned down by Kyle's mother, triggering Satan and Saddam Hussein's takeover of the world. All seems to be lost until Saddam insults Satan one too many times after receiving several brutal electric shocks from Cartman's V-chip. Satan finally stands up to Saddam and kills him, thanking Kenny for giving him the courage to get out of his abusive relationship, and grants him one wish. Kenny's wish is for all the horror and tragedy of the US-Canada war to be undone, even if it means going back to hell himself. [[ResetButton Within a matter of seconds, everyone who died in the war is revived and Canadian/American relations are restored.]] Also, instead of going back to hell, as a reward for his sacrifice, Kenny [[spoiler: is sent to heaven where he is greeted by large-breasted angels]].
* ''WesternAnimation/TheSpongebobSquarepantsMovie'' writes itself into a corner that can only be rectified by a wonderfully ridiculous parody of Music/TwistedSister's I Wanna Rock. The villain's plans are undone by the explosive [[ThePowerOfRock power of rock]] music. Once the smoke clears, [=SpongeBob=] is left dangling on the end of a rope suspended above the stage in a neat reference to the literal Greek tragedy deus ex machina.
* ''WesternAnimation/TheSecretOfTheHunchback'' has an egregious example: [[spoiler:In the ending, Quasimodo seems to fall to his death, but then... he GROWS WINGS]]!
* The [[spoiler:healing tears]] at the very end of ''Disney/{{Tangled}}''. While the movie is different in many ways from the original fairy tale, this detail comes straight from the source material. [[spoiler:The fact that her healing powers were rather mysterious to begin with may also be a factor]]. However, nothing in the movie itself foreshadows it in any way (unless you believe the theory that [[spoiler:the drop of sun from the intro ''is'' the tear that saved Flynn]]).
* '''THE CLAW''' at the end of ''WesternAnimation/ToyStory3'' is a ''[[FridgeBrilliance literal]]'' Deus Ex Machina, as the DVD commentary points out, given that the [=LGMs=] treat "the claw" as their deity and it is also the machine that [[spoiler: saves all of the toys from burning in the garbage furnace]]. Its arrival is accompanied by a choir of angelic voices on the soundtrack.
* The Amnesia-inator in ''WesternAnimation/PhineasAndFerbTheMovieAcrossThe2ndDimension''. Even though it was established that O.W.C.A. has been duplicating Doofenshmirtz's Inators, that one was never seen before in a previous episode. Likely PlayedForLaughs; Doofenshmirtz's response of "I think I'd remember building something like that!" suggests that the original backfired and gave ''him'' amnesia, thus forgetting he built it. Ironically, the previous episode "I Was a Middle Aged Robot" actually introduced a memory eraser, owned by O.W.C.A. no less. Apparently, they forgot about this.
** In the climax, Candace attempts to bring their Mom out to the battlefield to see it, as she believes that the "magical force" that always sweeps away her brothers activities before she can show their Mom will take care of things.
* This is truly the only thing keeping ''WesternAnimation/ATrollInCentralPark'' from having one of the worst {{Downer Ending}}s in the history of animated cinema, as Stanley is turned into stone in the climax - ''the very thing he was afraid of happening to him the whole movie'' - and the only thing that saves him in the end is the little boy just ''somehow'' getting Stanley's Green Thumb powers for no given reason that restore him.

[[folder:Music Videos]]
* In the Music Video for Music/CyndiLauper's ''"The Goonies 'R' Good Enough"'', Wrestling/AndreTheGiant appears out of nowhere (literally, just a puff of smoke, and there he is) to chase off the bad guys.

[[folder:Myths & Religion]]
* Funnily enough, there are many times in Greek Mythology where the gods and goddesses fail to do this all the way through; they may do something which only partly rectifies the situation or has its own shortcomings to it -- though that may be due to them being JerkassGods. Not all instances from classical mythology are subversions, though. For example, at one point Hera offers her aid to the Argonauts to get them through. It's the only time in all of antiquity when she was depicted as acting nice, let alone toward heroes. In fact, the entire name of the trope came from the theatrical device used (via a cherry-picker like machine) in ancient Greek plays based on the Greeks' myths.

[[folder:Radio Drama]]
* While writing the first installment of ''Radio/TheHitchhikersGuideToTheGalaxy'', Creator/DouglasAdams found himself faced with a writer's dilemma: His characters had just gotten thrown out an airlock, and would pass out and die from lack of oxygen in 30 seconds, and it was so utterly improbable that another spaceship would come around within those 30 seconds to rescue them that to have had that happen would've been nothing short of this trope. This gave him the idea for the Infinite Improbability Drive.

[[folder:Role-Playing Games]]
* ''Roleplay/AlphaTeamMissionDeepFreezeRPG'' had a recurring Deus ex Machina where characters on the brink of death would be confronted by a mysterious voice telling them "it is time", but could be convinced to bring people back. This was basically invented by Kotua in Space as a means of getting his character, who had been reduced to a ghost forced to possess vehicles in order to stay in this world, back into a physical human body in an easy and feasible manner. This happened several times with the same people. Given the context, this might very well be a literal case of Deus ex Machina. This was later parodied by ''Roleplay/DinoAttackRPG'', in which the voice outright scolded a man for trying to convince it to bring him back. The parody is taken even farther in a non-canon post, where the voice doesn't even give another character a chance to speak for himself and sends him straight into the afterlife.
* ''Roleplay/DinoAttackRPG'' has a number of Deus ex Machina instances of its own. There are probably too many in number to list them all, but here's a few notable examples:
** When the Dino Attack Team arrived at the base of the Ogel's Island volcano, they had no means of ascending the mountainside. Quite conveniently, Reptile's T-1 Typhoon crash-landed into the volcano and dropped off some climbing gear.
** Although set up and foreshadowed several posts before it arrived, the stampeding Triceratops herd that ended the battle for the Aztec Village was {{lampshade|Hanging}}d as a Deus ex Machina. Interestingly, unlike most examples of {{lampshad|eHanging}}ing, this was not PlayedForLaughs but [[PlayedForDrama For Drama]], since Rex realized that relying on a Deus ex Machina to save the day is a poor strategy that could easily backfire. Rex later attempted to {{def|iedTrope}}y Deus ex Machina by setting up a BigDamnHeroes in advance, only to be punished for it by the UnspokenPlanGuarantee.

[[folder:Tabletop Games]]
* In ''TabletopGame/DungeonsAndDragons'', the high-level Cleric spell Miracle allows you to request intervention from your deity. It costs experience points to use in that fashion, but other than that the only stated downside is that the deity might refuse.
* ''[[TabletopGame/FateOfTheNornsRagnarok Fate of the Norns: Ragnarok]]'' allows player characters to ask a deity to help them in battle. A sacrifice is performed, runes are drawn, and if the aforementioned deity is in a good mood, Deus ex Machina may occur. However, if your prayer has ''angered'' it, the divine intervention will benefit your opponents!
* In ''TabletopGame/{{GURPS}}'', a character can buy an Advantage called Serendipity, which allows one extremely fortunate event per game session to take place at the player's discretion. The Gizmos advantage is designed to let players imitate fictional characters like Batman and James Bond, as described above.
* The parody RPG ''TabletopGame/HoL'' has the "Grace of God" pool, which players can put points in by rolling {{Critical Hit}}s during the game. If the character cannot get out of a situation and has points in Grace of God, they can say "Praise Jesus", which allows the DM to use any random, nonsensical, and/or inexplicable means they can think of to solve the character's dilemma.
* In the tongue-in-cheek RPG ''TabletopGame/InNomineSatanisMagnaVeritas'', which is played with rolls of 3d6, anyone rolling 111 means a direct and usually over-the-top divine intervention happens. Which can be a very good thing if you're playing an angel, and a very ''bad'' thing if you're a demon. And of course, a roll of 666 causes a direct satanic intervention. Also, any angel can try to summon his archangel, and any demon can try to summon his demon prince. And yes, it ''can'' work... If you're lucky.
* ''TabletopGame/MagicTheGathering'' has the "Miracle" mechanic. Cards with Miracle are all powerful, expensive spells. However, if they're the first card their owner draws in a turn, they can be immediately played for their (deeply discounted) Miracle cost, making them a sudden solution to many a hopeless scenario.
* {{Lampshade|Hanging}}d in ''TabletopGame/{{Munchkin}}'': There's a card called Deus Ex Machinegun that has the gods come down with a machine gun and kill all the monsters, take all the treasure, and make the combat just magically go away.
* ''TabletopGame/{{Shadowrun}}'' actually has a rule about this, called Hand Of God. When a PC ends up in some sort of [[NoOneCouldSurviveThat hopeless situation]], the PC's player can invoke the Hand Of God, having the GM save the PC via some form of Deus ex Machina. There's a catch, of course: it has a hefty experience-point cost, and it can only be used once per character.
* In ''TabletopGame/SpiritOfTheCentury'' players may use their characters' Aspects, a Declaration, or even certain Stunts to make an unlikely coincidence happen. Players can also have gadgets and artifacts with undefined abilities, so you can decide that they do exactly what you want at the right moment (of course, once you've decided it stays that way at least until the end of the adventure)
* ''TabletopGame/WarhammerFantasyRoleplay'' and ''TabletopGame/DarkHeresy'' have the [[OneUp Fate Points]], which will unfailingly pull a character out of certain death and put them in a position where you are safe for the immediate moment. For small stuff a Fate Point will turn a killing blow to a glancing one, cause the enemies to take you prisoner instead of killing you on the spot, or let you dodge that lethal fall pit, but it becomes one of these when, say, you've just been killed by being spaced, caught inside a collapsing mine or building, or by having a daemon biting your head off.
* This is Modus Operandi for the Legion of the Damned chapter of Space Marines in ''TabletopGame/{{Warhammer 40000}}''. They appear without warning and aid beleaguered Imperial forces against the enemies of mankind, then disappear as soon as the battle is won just as suddenly as they came. Notably, this is one that creeps out the Imperials something fierce. Interestingly, one of the theories behind the Damned Legionnaires' appearance is that they are extensions of the God-Emperor's will. Although he's more like [[{{Pun}} Deus IN Machina]]. [[spoiler:[[DontExplainTheJoke You know, the Golden Throne?]]]]
* An actual game mechanic in ''World of Synnibarr'' (really). If your character is on the verge of death with no hope of salvation, you actually get a ''dice roll'' to see if your patron deity turns up to haul your arse out of the fire.
* For some {{Game Master}}s, this is going to happen eventually. Whether it be a TotalPartyKill where it shouldn't be, the players making a decision that turns out to be much worse than they could imagine, or other misadventure, a group of players will find themselves in a situation where the only way out is to basically cheat. Some [=GMs=] will just rewrite the then-latest events, but for [=GMs=] who like to maintain the narrative, this may be the only way out.

* In the prologue to his ''Amphitryon'', the Roman playwright [[Creator/{{Plautus}} Titus Maccius Plautus]] parodied and {{lampshade|Hanging}}d this trope somewhat by having the god Mercury explain to the audience that there's a precedent for having the gods be active characters in this play: wasn't it just last year that somebody performed a play on this very stage in which someone in dire straits called on Jupiter and (lo and behold) out popped Jupiter to save the situation?
* In the musical ''Theatre/CityOfAngels'', writer Stine finally snaps after witnessing the culmination of the ExecutiveMeddling on his FilmNoir screenplay, and the producer sics the studio cops on him. Detective protagonist Stone (appearing as Stine's SpiritAdvisor after his part was brutally miscast by the studio) goes over to Stine's typewriter and does a little RewritingReality, making Stine beat up the cops and defeat the producer. For an encore, Stone types a little more and reunites Stine with the wife he cheated on: "A Hollywood ending!"
* In Creator/JohnMilton's ''Theatre/{{Comus}}'', the Spirit complains that the brothers let Comus get away with his MagicWand so they can't free their sister -- but wait. He recounts the tale of how Sabrina (previously unmentioned) [[DeityOfHumanOrigin became a goddess]] and then calls on her to help them, which she does.
* Spoofed, perhaps even {{deconstruct|ion}}ed by Creator/WoodyAllen in his one-act play ''[[http://members.fortunecity.com/bookdepository/plays/god/god2.html God]]'', an excellent if strange production which has NoFourthWall whatsoever; it's nominally about two Ancient Greeks trying to put on a play right there, when [[ThemeNaming Trichinosis]] shows [[ThemeNaming Diabetes]] his new invention, a machine for lowering the gods to the stage in order to solve characters' problems. (He boasts that he's going to make a fortune with it: "Sophocles put a deposit on one. Euripides wants two.") Unfortunately, when turned on, it winds up strangling the actor playing Zeus.
-->'''Diabetes''': God is dead.
* ''Theatre/HellBentFerHeaven'': The dam has failed and everyone seems doomed to die in the impending flood—when Sid reveals that he wrangled a boat on his way back from the dam.
* The [[Music/WolfgangAmadeusMozart Mozart]] opera ''Idomeneo'' includes a literal example. Idamante is about to be sacrificed to Neptune, when the god's voice proclaims that he is to live instead and take the throne from his father.
* Creator/{{Euripides}} was so well known for using this device that in ''Literature/{{Poetics}}'', Creator/{{Aristotle}} singles him out when discussing why it's bad, while Creator/{{Aristophanes}} made Euripides a character in one of his plays and had him at one point enter the stage with a crane. Examples include:
** ''Iphigeneia in Tauris'' ends with Iphigeneia, brother, and his friend being pursued by enemies over the sea. A wind appears to make their escape more difficult -- but Athena appears to order the pursuit to stop. Many critics have noted that apparently Euripides introduced the wind, which serves no other plot function, ''solely'' in order to have an excuse to make Athena appear.
** ''Theatre/{{Alcestis}}'' resolves the seemingly unsolvable dilemma at the center of the play (the title character has agreed to die in place of her husband, and Death insists on taking one of them) by having Heracles show up and wrestle Death into submission.
** In ''Iphigeneia at Aulus,'' after Iphigeneia finally agrees to be sacrificed so that Artemis will stop holding back the winds keeping the Greek fleet from sailing, the priests come down in the final scene and say that when they looked away Iphigeneia had been replaced with a pig. Not highlighted for spoilers since she obviously lives if there's a sequel.
** In ''Orestes,'' Orestes and his sister have been condemned to death for murdering their mother (which Orestes was ordered to do by Apollo, since their mother killed their father, which she did because the father had killed their sister...). The two of them and Orestes' best friend Pylades have escaped, taken Orestes' fiancée hostage, and are holed up in the palace ready to burn it all down around them... when all of a sudden Apollo pops in, orders everyone to stop fighting, and ensures that all of the leads are friends and/or married. This ending is traditionally read as Euripides having written himself into a situation where none of his characters could be expected to solve things without divine intervention. However, more modern readings of the play as a StealthParody (as in Anne Carson's super-snarky translation), suggest that we are fully meant to notice how arbitrary Apollo's solutions to the characters' problems are.
* Mrs. Winter's arrival at the end of ''Nice Work If You Can Get It'' serves only to resolve all plot conflicts, clear a few mysteries, and allow for a happy ending for all.
* In ''Theatre/PokemonLive'', the original Mewtwo shows up and saves the day, using his telepathy and Ash's heart to give [=MechaMew2=] a Care Bear Stare. There was no way he could defeat Giovanni on his own, especially since Pikachu had already been knocked out.
* Parodied in P.D.Q. Bach's ''The Stoned Guest''. At the end of the opera, [[KillEmAll every character is killed or otherwise dies]]. Then, for literally ''no reason at all'' ([[ExecutiveMeddling other than the arbitrary decree of the composer's patron, who didn't like the original ending]]), they all spring back to life and sing about how it's a happy ending.
* Creator/{{Moliere}} tended to lean on this to wrap up many of his comedies. In ''Theatre/{{Tartuffe}}'' the protagonists are saved in the last act when a police officer shows up out of the blue with an order from the king arresting the villain. The conclusion of ''The School for Wives'' is so bizarrely complicated that we're still not quite sure what happened, but the gist is that the starcrossed lover's respective families show up to let them know that they had arranged their marriage years ahead of time (without either of them knowing it).
* Parodied in the [[Creator/BertoltBrecht Brecht]] play ''Theatre/TheThreepennyOpera'', where the playwright actually goes to the length of having his characters explain that the play really ends differently... but, for the sake of a happy ending, a royal official enters on horseback to make everything better. The play ends with a comment saying how unlike real life this is.
** There's an inversion of this trope in another Brecht play, ''The Good Person of Szechuan''. Just as things have got as bad as they can possibly get for the protagonist, Three Gods (who have been present on Earth since the opening scene, and in fact were responsible for the protagonist's predicament in the first place), pointedly do ''not'' step in to resolve matters, and instead mount a giant pink cloud and ascend into the heavens.
** Brecht was very fond of parodying - and thwarting - an audience's need for closure and happy endings, as it was part of his theatrical manifesto to leave an audience ''un''satisfied, and thus hopefully motivated to go out into the world and change things for the better.
* Creator/GilbertAndSullivan often used these (or very out-of-left-field [[TakeAThirdOption Third Options]] disguised as these) to resolve their plots. Which ones are straightforward Deus ex Machinas and which ones are parodies or subversions can be an interesting subject for debate.
** ''Theatre/HMSPinafore'' is certainly one of the more genuine examples; although Little Buttercup often hints that she has a dark secret, and there is a more subtle clue in [[spoiler: Ralph's erudite vocabulary]], nothing in the play could remotely help an audience think that [[spoiler: Ralph and the Captain being switched at birth]] is even plausible in the world of the play, let alone that [[ContrivedCoincidence Buttercup would have been involved]] plus on board at the right time to reveal it, etc., etc. But hey, look at that, it happens to solve both the A- and B-plots in one fell swoop! Cue the finale, it's time to go home!
** ''Theatre/ThePiratesOfPenzance'', on the other hand, is a definite parody. Not only have wacky plot elements been present from the beginning of the operetta, but there has been plenty of foreshadowing of Ruth's final revelation ([[spoiler:that the pirates are really noblemen]]); from the first line of the first song, in fact! (Examples:[[spoiler: they drink sherry instead of rum or grog, they hold fast to their code of honour even when it leads to their constant defeat in battle, and there is ''an entire song'' about how it's better to be a pirate king than a real one]]). In the same opera, the police deliberately try to invoke this. At the moment when they are most hopelessly defeated in battle, they... call on Queen Victoria: The mere mention of her name makes the pirates give up instantly out of loyalty to her.
* Creator/WilliamShakespeare was generally good at averting and subverting this. ''Theatre/MeasureForMeasure'' has an ending that probably seems like Deus ex Machina to the characters, but the audience spent the entire play watching the Chessmaster set it up. ''Theatre/AMidsummerNightsDream'' ends amicably when the fairies step in and fix everything with magic, but it takes them three tries to get it right and in the meantime they screw everything up even worse. The ending of ''Theatre/TheWintersTale'' is either this or FridgeBrilliance, depending on how you read it (although it did [[ExitPursuedByABear name a trope]] that is usually a DEM).\\
Some straight examples:
** The final scene of ''Theatre/AsYouLikeIt'' has a normal one and a ''literal'' one: Jaques, the never-before-seen [[CainAndAbelAndSeth brother of]] [[CainAndAbel Oliver and Orlando]], shows up inexplicably in the Forest of Arden to announce that the usurping Duke Fredrick has [[HeelFaithTurn found religion]] and restored his dukedom to his banished brother. But before that, Hymen, the literal god of marriage, shows up to resolve romantic subplots and make predictions in rhyming couplets.
** In ''Theatre/TheComedyOfErrors'' an abbess we've never seen before shows up, and she's the long-lost wife of Egeon and mother of the Antipholuses, one of which had been living in the same town with her all this time and never knew.
** Occurs offscreen in Shakespeare's ''Theatre/{{Hamlet}}'', between 4.4 and 4.6: [[spoiler: on the way to England, Hamlet is kidnapped by pirates, who kindly return him to Denmark]].
** In ''Theatre/TheMerchantOfVenice'', Portia produces a document at the end which reveals that [[spoiler: Antonio's ships didn't sink after all and he is still rich]]. It is never explained how she got this information or why she didn't reveal it before [[spoiler: Shylock lost everything he owned and Antonio ''nearly died.'']]

* Happens quite a bit in Toys/{{BIONICLE}}, but three particular examples stand out:
** In the final moments of the Bohrok-Kal arc, Tahu summons the [[MaskOfPower Kanohi]] [[TimeDilation Vahi]], which gives the Toa Nuva just enough time to defeat the Kal, who were literally only seconds away from victory. There was no prior indication that Tahu had the Vahi (though the novelization ''Makuta's Revenge'' fixes this).
** In the Toa Inika's battle with Vezon, Jaller pulls out a unique Zamor Sphere that freezes Vezon in stasis, allowing the Inika to recover the Mask of Life. Unlike the Vahi example, there ''was'' a scene of Axonn giving Jaller the sphere, however its power was never explained,[[note]]The most Axonn says is that it's "for protection"[[/note]] which raises a lot of FridgeLogic.
** In the GrandFinale ''Journey's End'' arc, completely out of the blue, the Mask of Life creates a mystical set of Golden Armor for Tahu, which is capable of annihilating every single Rahkshi soldier ''and'' [[PowerCopying gaining all their abilities]]. This is said to be a contingency plan of the Great Beings, for if The Makuta ever rebelled. It was never mentioned prior to this, and you'd think it would've activated a lot sooner [[FailsafeFailure if it supposed to be a fail-safe]].

[[folder:Visual Novels]]
* In VisualNovel/SuperDanganronpa2, the characters are forced to make a SadisticChoice: either A. [[spoiler:"Graduate", which would replace their memories of being the most dangerous terrorists alive who brought about the end of the world with the memories of the time they spent in the virtual world, reforming them and giving them hope for the future. This, however, would release a malevolent ArtificialIntelligence (specifically that of their leader during their time as terrorists) which would infect every person on the planet, essentially turning it into a world of nothing but copies of said leader, plunging the recovering world into a permanent state of blood, horror, and, most especially, despair. Oh, and it would also trap a couple surviving characters from the first game inside the virtual world.]] Or B., [[spoiler:activate the "Forced Shutdown", resulting in them losing all of the memories they've acquired in the virtual world and revert back to being the horrible terrorists (who are also physically mutilated), with a chance of being executed. However, this would completely destroy said malevolent AI, saving the world.]] They choose option B. The ending of the game reveals that [[spoiler:after getting out of the program, the characters decide to stay on the island and try to revive their friends who died inside the virtual world (of which there is a very, very small chance of pulling off), peaceably seeing off said first-game characters who put them in the program in the first place.]] Obviously, [[spoiler:they didn't simply revert to their old terrorist selves; either the Forced Shutdown replaced their terrorist memories with their virtual ones, or they now have both sets of memories.]] Either way, [[spoiler:there was no foreshadowing or explanation given for how or why the program would behave in such a way]].

[[folder:Web Comics]]
* ''Webcomic/BobAndGeorge'', where rather often various "convenient plot devices" were thrown in (to the point that even the author of the series himself became a regular cast member).
* [[Webcomic/DinosaurComics T-Rex]] explains it in his inimitable style [[http://www.qwantz.com/index.php?comic=1354 here]].
* In an apparently unintentional {{lampshade|Hanging}}d example, Miranda of ''Webcomic/DominicDeegan'' has taken to calling herself "Deus Ex Momina," being a rather jarring ParentExMachina in what is neither a sitcom nor starred by a teenager. WordOfGod states the joke was her terrible delivery of the joke rather than being one of the most MetaGuy moments the comic's ever had. There are other events where this happens, sometimes even being mentioned by the cast. "[[http://www.dominic-deegan.com/view.php?date=2004-03-01]]"
* The plot of ''Webcomic/ErrantStory'' is kicked off when Meji casts a spell to invoke a Deus ex Machina so she can find a way to complete her senior project and graduate from wizard school. As a result, she accidentally discovers, in the school library, the only surviving copy of a book that contains some information that the elves were trying to keep secret. Oddly, despite the [[LampshadeHanging name of the trope being mentioned]], this is ''not'' a normal example of the literary trope, because it serves to drive the plot rather than resolve it.
* In ''Webcomic/GameDestroyers'', Ferahgo is a purposeful example of this, and Jipples has become a minor, though lazy, example of this as well.
* ''Webcomic/KevinAndKell'' has seen its fair share of these in its [[WebcomicsLongRunners two decades as a comic]]. One arc [[http://kevinandkell.com/2011/kk0608.html from June of 2011]] involving factional elections amongst rabbits comes to an end with a completely unexplained, contrived resolution that [[StatusQuoIsGod restores the status quo]], just in time for [[InvincibleHero the Dewclaw family to escape their latest conundrum.]] Made all the more jarring by their salvation in this situation spontaneously appearing and disappearing with no indication from where or why it came and left as it did. Even if [[http://kevinandkell.com/2011/kk0623.html the final strip]] is a hint to who saved the day, it's still never mentioned before or after.
* ''Webcomic/MagickChicks'': At the end of chapter 15, [[spoiler: [[EvilRedhead Cerise]]]] mass teleported the student council to their {{uncertain doom}} and she was the only one who knew their location. You'd think it would've paved the way for a RescueArc, or that she'd be forced undo the spell and return them. Nope. Near the end of chapter 18, the wand became [[PlotDevice an all-purpose problem solver]] by enabling Mel to sense they were alive, [[spoiler: [[http://www.magickchicks.com/strips-mc/she_was_alive instantly whisked her to where they were, and back]]]], in less than a minute.
* ''Webcomic/TheOrderOfTheStick'': The [=MitD=] plays this role in [[http://www.giantitp.com/comics/oots0661.html this comic]]. While the Monster in the Darkness is a mystery to everyone except Rich Berlew; this new ability introduced comes right out of nowhere and at the most convenient of times for our heroes. The fact that it also reunites them back with their friends does not help. [[http://www.giantitp.com/comics/oots0441.html This comic]] also features something that is hard to accept at face value (no air turbulence and coincidence). It's deliberately played off under RuleOfFunny so it is excusable, but still tastes like a WriterCopOut. Receives {{lampshad|eHanging}}ing [[http://www.giantitp.com/comics/oots0504.html here]]. Also, while it's not quite an example (there are a few hints), the comic {{lampshade|Hanging}}s how close it is to this when [[spoiler:Julio Scoundrel arrives just in time to save the Order of the Stick from Elan's father in his flying airship. The name of his airship? ''The Machina'']].
* LampshadeHanging: In ''Webcomic/QuestionableContent'' the cast are trapped in an alley by a crazed KnightTemplar / AntiHero and her robot {{Sidekick}} until they are saved at the last minute by their own [[RobotBuddy robot sidekicks]] under the battle cry "Deus Ex Machina!". QC, one should note, is set in a slightly-warped version of the ''real'' world, somewhere between MundaneFantastic and a [[SpeculativeFiction sci-fi]] or {{superhero}} world.
** The introduction of Spookybot and quick resolution of Bubbles and Faye's problems with Corpse Witch is arguably another example.
* Justified: ''Webcomic/SluggyFreelance'' features a literal Dea Ex Machina who is not a literary Deus Ex Machina in the "[[http://www.sluggy.com/daily.php?date=040519 That Which Redeems]]" story arc. The goddess of good has been trapped in the Demon King's refrigerator since the conquest of her world, but as the story had been told within the comic years previously, her appearance was widely predicted by the readers. So when she's freed from the fridge and sets things right, no one's really surprised.
** Also in that unsealing the goddess was a Torg's deliberate goal that he struggled and sacrificed for, whereas a Deus Ex Machina is by definition easy and out of nowhere. This is really more SealedGoodInACan (though if it were a can instead of a leaky ziplock, we'd be short several plotlines).
** The "Holiday Wars" arc plays with it and provides a DoubleSubversion. We learn that there exist three magic "Deus ex ova", Latin for "God from the eggs", magic eggs created by the Greek gods that will hit the ResetButton if broken, and that Bun-Bun's main antagonist SantaClaus has one of them. Finally, when Santa is left with no other options, he tries to use it, but [[spoiler: Bun-Bun, being the Easter Bunny, has hidden the egg]]. Later, [[spoiler: Bun-Bun himself is forced to use it to save his own life, magically bringing all of his enemies back to life and defeating him, but leaving him alive]].
** The end of 'Oceans Unmoving' literally has a god from out of nowhere, or at least his blood relative. While the sudden appearance of the brother of a Time God living in the basement of a timeless dimension is thematically consistent, he really seemed to appear just in time to wrap up the storyline quicker. Bonus points for wrapping the continuity to the beginning of the series though, and explaining Bun-bun's appearance without revealing any mysteries about his past. This is {{lampshade|Hanging}}d, since Uncle Time automatically assumes that Bun-Bun [[RiddleMeThis solved his riddle]], which led him there. Bun-Bun has never even heard of the riddle or Uncle Time, despite all of the lore and myths that the story invokes.
* ''Webcomic/SchlockMercenary'' on several occasions. Also {{lampshade|Hanging}}d [[http://www.schlockmercenary.com/d/20050319.html here]].
** The Petey-focused extra story in the printed version of book 7 is actually called "Deus ex Nausea", as scenario after scenario is resolved by sudden Fleetmind interference. He's actually trying to subtly kill the literary device in several cultures in an attempt to make them more self-reliant, which gets awkward when he's simultaneously acting as one.

[[folder:Web Original]]
* [[http://www.wowwiki.com/Chronicle_of_the_Annoying_Quest Chronicle Of The Annoying Quest]] features a character ''named'' "Dues X. Machina" (Pronounced "doose"). The name seems to be an ironic joke, however, as he doesn't actually do anything plot-related in his first appearance (though he does provide another excuse for [[HilarityEnsues hilarity to ensue...]])
* The 7th ''Literature/ChronoHustle'' story, which is in fact title Deus Ex Machina, involves a situation where Jack Masterson is about to be raped by Aphrodite. He has no way out of the situation when suddenly [[spoiler:Hermes]], who had not been so much as mentioned up to that point, shows up. He [[spoiler:doesn't actually save the day, but does provide enough of a distraction to give the rest of the main cast time to show up.]]
* In ''Roleplay/TheGamersAlliance'', when Leon is about to die in battle, a black wolf appears all of a sudden and saves his life. It later turns out that the wolf was in fact [[AntiVillain Kagetsu I]] whom Leon had unknowingly freed earlier. [[{{Pun}} Technically Kagetsu was only a half-god, though]].
* In [[WebVideo/HBomberguy [=H.Bomberguy's=]]] video on the 2017 British Election, the horror of having to live through another Tory government is immediately resolved when [[spoiler:the money birds come back home]]
* In ''[[WebOriginal/{{KeitAi}} Keit-Ai]]'', an unexplained deus ex machina is responsible for letting a boy get the phone number of his crush, only to realize later that it was actually from the [[AlternateUniverse alternate universe]] [[AlternateSelf version]] of his crush instead.
* When [[Literature/TheLayOfPaulTwister Paul Twister]] is right about to get caught by a guard, an angelic warrior whose life he had saved at the beginning of the story shows up to conveniently provide a distraction, just long enough for him to get away. Paul is a bit freaked out by this, since it seems to have come out of nowhere and required knowledge that she shouldn't have had, and he figures that [[ThisIsGonnaSuck whatever he's caught up in is probably about to get worse.]]
--> Things like that just didn't happen to me, suddenly being bailed out by an unexpected ally, just seconds after being caught flat-footed. And she was a Celestial, to boot. [[LampshadeHanging Seriously, all that was missing was the ''machina''!]]
* Averted during the course of [[WebVideo/TheNostalgiaChick The Dark Nella Saga]] with the jar of mayonnaise. While it does allow for teleportation [[spoiler:and resurrection]] it was shown being injected with "a plot device" by Lord MacGuffin early on in the saga. The only remaining question is how [[MadScientist Dr.]] [[HotScientist Tease]] got the jar in the first place...
* Anything classified as [[spoiler:Thaumiel]] by ''The Wiki/SCPFoundation'' essentially works as this trope, being objects that could be of benefit to the Foundation. Of particular note is SCP-[[http://www.scp-wiki.net/scp-2000 2000]], which basically [[spoiler: acts as a ResetButton to clone humanity in the event of an apocalypse.]]
* ''WebVideo/SomeJerkWithACamera'': After accidentally erasing his own birth at the very end of his "It's a Small World" review, Jerk is saved by a dimensional figure called The All-Being, who transports him to an alternate universe that's exactly the same as his old own.
* {{Lampshade|Hanging}}d in [[http://onering.legendaryfrog.com/movies_or2_w.php The One Ring to Rule Them All 2]]. Frodo and Sam escape their lava trap with no other explanation than "plot device, Mr. Frodo, plot device".
* PlayedForLaughs in Website/TheOnion Sports Dome reporting a collapse of the Staples Center had brought an early end to a basketball game between the Los Angeles Clippers and the Phoenix Suns where the home team Clippers were on the losing end of a CurbStompBattle.
* Critics of the ending to ''Roleplay/SurvivalOfTheFittest'' v1 tend to claim that the only reason that Adam Dodd won was a series of these. Others who believe that the alternate universe "Afterlife" RP signifies the existence of the supernatural in SOTF claim that the spirits of [[TrueCompanions his dead friends]] may have been [[ThePowerOfFriendship protecting him]].
* Averted in VGHS, season 2: The Law [[spoiler:Is saved from Shane's men by Robot ShotBot. It is a Deus Ex Machina even more considering that he is saved by a machine, but we must consider that ShotBot's intervention was foretold in the beginning of the episode, and that his presence really is useful for the next events: ShotBot stays on track and makes the narration progress]].
* ''Film/NoobLaCroiseeDesDestins'': At the very en of the movie, Gaea, a StarvingStudent who's trying to live off schloarship as long as she can according to AllThereInTheManual, get an inverted case of HeroismEqualsJobQualification (in that the act that lands her the job is awesome, but otherwise villainous). The character who offers her the job is a pre-existing minor character that gave absolutely no previous indication of being in a position in which he could offer her such a job.
* ''WebAnimation/SuperMarioBrosZ'': In Episode 7, Kolorado's grandfather's stopwatch was revealed to [[spoiler:house an ancient magic which proved to be the only thing capable of negating the curse trapping the characters within the MinusWorld, allowing them all to escape]]. Alvin-Earthworm, the series creator, criticizes himself for writing this into the episode, and he intends to omit this episode from the reboot as a result.