Dead Ex Machina

When things are at their worst and the hero is all but defeated, timely intervention by a Back From the Dead character saves his life and gives him the Heroic Resolve to keep fighting. Usually the character in this case really is dead and appears as a spirit, but sometimes it's the character's return from a Disney Death, or their apparently fatal injury turns out to be Only a Flesh Wound. Rarely, this is when it's revealed that the Instant Death Bullet wasn't so instant after all, and Almost-Dead Guy performs this one final heroic act before expiring in the aftermath with a drawn out Final Speech.

Sometimes, usually in more realistic works, the intervention isn't physical at all, but happens entirely within the hero's head, often giving an excuse to bring back the actor of a fan favorite who had been ill-advisedly killed off by the writers. This only takes an instant of real time, but can take several minutes of Dead Person Conversation before returning the hero to the action. The hallucination of a dead friend is apparently enough to get the hero back on his feet, though, realistically, it should be evidence of some sort of massive head trauma.

This trope frequently immediately precedes a Crowning Moment of Awesome.

This is a sub-trope of Deus Ex Machina that specifically plays with our automatic assumption that character death is permanent. Compared to Dead Person Conversation, this is urgent and immediate: the dead person saves the day, either physically or by imparting some sort of Epiphany Therapy.

Aspiring writers seeking to avoid using this trope should wander over to How to Stop the Deus Ex Machina.

Anime and Manga
"Wolfwood: What're you doing, needle-noggin? It's right next to you! Use it!"
 * In Akira, the titular character manifests just in time to destroy Tetsuo and teleport Kaneda to safety.
 * Not so much "destroy", as "merge-with-to-become-a-new-universe".
 * In the Dragonball Z anime, Goku sees images of Vegeta when he's losing his fight against Freiza (reminding him of what happened to their race).
 * His dad and King Vegeta also showed up. Also, for some reason, Vegeta is naked. Yes, Goku is imagining Vegeta naked. Damn you Toei!
 * And we can't forget the final battle against Cell, where Gohan is cheered on by Goku's spirit in the middle of a Beam-O-War, going so far as to mimic the Kamehameha stance. The scene was so memorable that several of the games have included the "Father-Son Kamehameha" as its own attack. Better yet, since Goku can teleport and his spirit was shown to be watching the situation, it's entirely possible he was actually there.
 * The every-party-member-contributes climactic sequence of Final Fantasy VII: Advent Children includes Aeris in the set of those helping Cloud despite the fact that she died well before those events, at the end of the first disc of the original game.
 * Not to mention, it's Aerith's will that summons the final cure for Geostigma.
 * Near the end of Advent Children Complete, Zack makes an appearance and basically shames Cloud into handing Sephiroth his own ass on a silver platter, with a side of ownage gravy (he also offers to help Cloud in the fight, though Cloud declines).
 * Joe, from Martian Successor Nadesico's from show-within-a-show, Gekiganger 3, comes back from the dead to save the heroes in the final battle- all the Martian Successor Nadesico characters who see this comment on how stupid of an ending it is.
 * In Ghost in the Shell 2, the Major, though not, strictly speaking, dead (though the other characters talk about her as if she were), does inhabit a Sex Bot body to save Batou's ass in the finale before returning to the vast reaches of Cyberspace.
 * In the Yu-Gi-Oh! anime, Yugi gets help from all his petrified friends in his head before playing his last turn in the duel against Noah.
 * Kamina makes a return in the second-to-last episode of Tengen Toppa Gurren Lagann and makes Simon reject the The Final Temptation put before him. Whether it was actually his ghost, or simply a representation of Simon's ability to resist, isn't clearly stated, but it was thoroughly awesome all the same.
 * A minor example from Trigun, in the final episode. Vash is all but defeated, with Knives about to blast him into oblivion. Then comes the immortal line below, which leads to Vash grabbing 'it' (the Cross Punisher BFG) and using it to win the fight.


 * Shadow Skill actually does this twice in the same battle. As Gau gets utterly stomped by Ren Fuma, Kain Phalanx blocks Len's fist and offers words of encouragement. After Gau gets the lead out and actually fights, Diaz Ragu shows up one last time to push his adopted little brother to victory.
 * Subverted in the Bleach filler arc, where Ichinose, who was seemingly killed by Kenpachi several episodes earlier appears to get involved with Ichigo's fight with the Big Bad. Ichinose pulls a Heel Face Turn (just before getting offed), but it extends even further, as the villain's lighting strike finishing blow on Ichigo is intercepted, when it's attracted to Ichinose's Zanpakuto like a lightning rod.
 * A very indirect version happens in the first Appleseed movie. Deunan is struggling to prevent the release of a virus that would wipe out all bioroids, which is only possible by entering a certain password into a computer on top of a gigantic mecha that's trying to kill her. The password, appropriately, is the name of a bioroid friend who died earlier in the movie. During the fight, the keyboard becomes damaged and she is unable to enter the last two letters of the name. With time running out, she sends a last desperate prayer to her mother, and the two letters appear on the screen just in time to press enter and save the world. This scenario earns bonus points for its Maybe Magic, Maybe Mundane application; it can be explained as either the intervention of either spirit involved, or just the luck of the keyboard finally working in time.

Comic Books

 * In DC's Final Crisis, the Barry Allen Flash, who had been dead for twenty years in standard time, outruns The Black Racer and leads it to Darkseid, saving the world.
 * He does something similar in Infinite Crisis, helping trap Superboy Prime in the Speed Force.
 * Subverted (of course) in Watchmen: Ozymandias tricks Dr. Manhattan into a field generator that disintegrates him. Dr. Manhattan re-integrates moments later, only to realize that Ozymandias's plan has a chance of working for the betterment of humanity. Manhattan lets Ozymandias win.
 * In Whatever Happened to the Man of Tomorrow?, It's the opposite from the usual. Lex/Brainiac is killed at one point, but later, as Jimmy's trying to undo Brainiac's force field generator, a beam kills him instantly. Who fired it? Brainiac, still having control over Lex's muscles. Oh, and the force field was still up.

Film

 * Just before the climactic battle of Conan the Barbarian, Conan prays to Crom for the first time, saying that, you know, you could help if you wanted, but if not, screw ya. When Thulsa Doom's Dragon has Conan on the ropes, Valeria, the warrior-woman love interest killed by Doom earlier, appears in Valkyrie-like armor, blocks the attack, utters her catchphrase ("You want to live forever?"), and disappears. Conan proceeds to stand up and mop the floor with The Dragon.
 * In the books, the same character is known as Belit and is a pirate queen.
 * Ironically, this could be directly caused by Crom lending a hand. It's not stated in the movie, but in the books it's basically stated the Crom HATES prayer. Folks looking for handouts get none, while people striving on their own are looked at favorably but don't need help. Crom's help is reserved for those who strive against impossible odds to the very end of their strength. It helps that Conan's prayer shows just the right mix of respect and derision to make the god chuckle and take notice.
 * In Terminator 2: Judgement Day, the Skynet-serving T-1000 destroys the power cell of the reprogrammed T-800 protecting John Connor. He eventually revives himself by re-routing power from a different source, arriving just in time to knock the T-1000 into a vat of molten metal and save John and Sarah Connor. It's arguable that this trope doesn't apply because machines aren't alive, and thus can't die, but come on... by the end, he knows why people cry.
 * Then in Terminator 3 Rise of the Machines, the T-850 shuts itself down rather than go through with its reprogrammed objective to kill John. It returns later by dropping a helicopter on the T-X.
 * As in the Comic Book, Watchmen has a scene at the end featuring a subversion by Dr. Manhattan.
 * In The Fountain, the main character's late wife appears to him in the future setting and urges him toward his final epiphany.
 * In Star Wars: Episode IV, Luke Skywalker is encouraged to use the Force to guide his attack run against the Death Star by the disembodied voice of Obi-Wan Kenobi.
 * As per the title, late Dr. Frankenstein appears to his son Ludwig in The Ghost of Frankenstein to convince him giving a new set of brains for the Monster, instead of destroying it.

Literature

 * In Stephen King's The Stand, Nick Andros tells Tom Cullen what he needs to do to save Stuart Redman's life during the winter in the mountains. Tom doesn't know that Nick is dead.
 * Richard K. Morgan seems to like this trope. In his Altered Carbon, Takeshi Kovacs often ends up speaking with one of his dead squadmates when he's in very stressful situation. In Thirteen, the very similar antihero hears his old mentor talk to him when he's stressed. Dick likes to say that the two are completely different; Carl is defined by his genes, while Kovacs is whatever the body he was downloaded into, but come on. They're the same character, with different names.
 * Happens in Dan Abnett's Warhammer 40000 Gaunt's Ghosts novel Straight Silver, when sniper Larkin passes out in the middle of a pitched battle. During a halucination, his dead friend Bragg appears and tells him to wake up. Note that at the time, Larkin actually is suffering from massive head trauma.
 * Happnes again in one of the latter books, when the Ghosts are assigned to hold a hopeless position many of them see - and are helped by - dead ghosts. It turns out to be moral support from affar by
 * A post-climatic example occurs in Sabriel, by Garth Nix: after having been mortally wounded by Kerrigor, Sabriel willingly lets herself float down the river of death - but the spirits of Abhorsens send her back to Life, urging her to carry on.
 * A very similar thing happens at the end of Abhorsen as well: the Disreputable Dog meets Nicholas at the First Gate, and after a little conversation, she sends him back into Life, for Lirael's sake. Manages to be a Crowning Moment of Awesome, Funny, and Heartwarming at the same time.
 * In Scarecrow, Mother blocks a guillotine blade with a shurikan when it was about to decapitate Scarecrow. He was still locked in the stocks, but her arrival was enough of a distraction to get him out.
 * Happens with Belit in the Conan the Barbarian books. (Valeria in the film.)
 * In The Lion, the Witch and the Wardrobe, Peter and friends are fighting a losing battle against the White Witch and her minions, when the resurrected Aslan shows up and saves the day.
 * In Animorphs, in an alternate timeline, Cassie is killed, but later reappears to save the day. Being "sub-temporally grounded" and somewhat immune to the effects of the time changes, she is able to return because she is "supposed" to be alive. Time basically got confused.

Live Action Television

 * In Supernatural's Season Two finale, John Winchester, the father of the leads, emerges from Hell just in time to prevent the Yellow Eyed Demon from killing his boys. Somewhat justified, in that there's an open gate to Hell ten feet away, and hundreds of demonic souls are escaping, too.
 * And Mary Winchester beat him to it in a Season 1 episode, where her ghost shows up and tells the Monster of the Week to leave her sons alone.
 * In Terminator: The Sarah Connor Chronicles, Sarah, after being shot in the leg and needing to escape a hospital, is visited by Kyle Reese, the (supposedly) dead father of her son and future savior of the human race comes to her and talks her through her escape and getting alternate medical help. This is a slight aversion, because Reese hangs around for most of the day, talking to her in real time (with her answers confusing other people who can't see him and making it clear that she's basically hallucinating) instead of just appearing at one critical moment.
 * In the season two premiere of Veronica Mars, the ghost of Lilly Kane shows up to lead Veronica away from the doomed bus, saving her life.
 * Done (more slowly than usual) in The West Wing: Mrs. Landingham dies in the middle of the arc where President Bartlett has to admit to America that he has Multiple Sclerosis. She shows up again for a few minutes when Bartlett's alone, just before a press conference at which he had been planning to announce that he would not seek reelection, and gives him one of the best pep talks anyone on television has ever received.
 * In Warehouse 13, the female lead gets into a car crash and is visited, apparently in the hospital, by a dead partner, who tells her to "Get up!" She wakes up next to the wrecked SUV and is able to pull her new partner out of the vehicle to safety.
 * Happens in Neverwhere. Sure, the audience already knew, but Richard didn't.
 * Subverted in Bones. Booth sees his dead friend who helps him to escape from a trap. A few episodes later it turns out that it actually was due to a brain tumour.
 * Except that they only think it was due to the brain tumor, Bones also saw his friend when they were at the cemetery but she didn't realize he was anyone other than some random soldier.
 * In series two Being Human (UK), the Big Bad was seconds away from killing Mitchell, George and/or Nina when the previously-exorcised Annie temporarily breaks out of Hell just so she can grab the guy and haul him back in with her. Yeah, it's that sort of show.

Webcomics

 * Order of the Stick has most of the Sapphire guard rise a 'ghost-martyrs' and join their founder (also dead) in defending Soon's Gate. Crowning Moment of Awesome? You bet! Right up until Miko ruins it.

Web Original

 * In Klay World's movie, King Womp is about to kill Chip, but Dr. Bob stops this by throwing an ax into King Womp's back, causing King Womp to fall and land on top of the structure the Klaymen built. King Womp was then shocked and blown up. OUCH. Chip was, obviously, saved in the process.

Western Animation
"Bart: Ralph! I thought you were dead! Ralph: Nope!"
 * In Ice Age, Diego the sabertooth tiger suffers a Disney Death, only to later come back to save Manny and Sid from the other sabertooths. Given the aversion to killing characters at all in some media, it's about as close as they'll get to this trope.
 * Near the end of Transformers Cybertron, Vector Prime appears to Optimus Prime when the final battle with Galvatron isn't going so well, and lets him use his sword (which is somehow quite tangible once he takes it.)
 * Parodied in an episode of The Simpsons telling the story of David and Goliath. When it looks like Nelson (Goliath) is about to kill Bart (David), Ralph appears and throws his tombstone at Nelson's head, even though Nelson had apparently killed Ralph earlier in the episode.

Video Games

 * In Star Fox 64,  (or at least, his ghost?) shows you Venom's escape route after defeating Andross.
 * Metal Gear Solid: Grey Fox
 * In Resident Evil 2, Ada Wong gets killed by a Tyrant, but appears in the shadows at the end to toss you a handy rocket launcher at a critical moment to finish off that same Tyrant. While some bioweapon and clone explanations were tossed around, it ended up that, in stark contrast to the brutality of her death, this is a case where her status as an Ensemble Darkhorse allowed her a more-improbable-than-usual Unexplained Recovery to account for her future appearances in the series.
 * Persona 3 In the final battle, the main character, finding that mere weapons will not avail him against Nyx, the incarnation of Death itself, goes into a lone face-off against her, where his allies give him strength (in the form of hit points) to cast the final spell and seal Nyx away from Earth. After his living teammates have said their piece, all you hear is the voice of Shinjiro (no text), who was the mid-game Heroic Sacrifice, saying "Let's do this." Then, and only then, does he have enough Hit Points to cast the Seal.
 * There's an optional one before this. Just before the final battle, the main character is given the Eleventh-Hour Superpower in a cutscene that gathers the wishes of all completed Social Links. This includes Akinari, the Sun Social Link... referred to by the game as the "Dying Young Man". The last time you meet him in his Social Link, it's implied that he's died and you're speaking to his ghost, and the epilogue confirms his death.
 * When everybody is shown praying for the cast before the final battle of Final Fantasy IV, old Tellah appears.
 * And in Final Fantasy V, five dead characters get to actively protect the heroes against an all-devouring über-spell.
 * In Jade Empire, Sagacious Zu turns up during the last boss' attempt to trap you in your own mind, and shatters his hold on you.
 * In Final Fantasy VII, it is all but stated outright that Aerith's will is the driving force behind Holy to work with Lifestream to save the Planet from Meteor.
 * This idea was at the core of the Japanese-only novella The Maiden Who Travels the Planet where Aerith and other characters who had died during the course of the game really do drive the Lifestream to save the Planet.
 * She shows up again in Advent Children as the final link in the chain of Cloud's Combined Energy Attack.
 * Used yet again in Advent Children Complete when Zack gives Cloud a mental pep talk in the middle of his fight against Sephiroth.
 * Since Cloud spent some time in the Lifestream during the game piecing his fragmented psyche back together with help from Tifa, it's quite possible they were speaking to him directly from said Lifestream.
 * Reversed in Ghost Trick.  is supposed to be alive, but when he turns up dead
 * In Tatsunokovs Capcom, one of Batsu's super moves is a Combination Attack with his partner. If his partner has been defeated, however, he cries Manly Tears and attacks alongside the partner's ghost. This version of the attack is more powerful than the combined one.
 * In the final battle of Wild Arms 2, the protagonist uses a series of Combined Energy Attacks fueled by the wishes of everyone on Filgaia. The final attack, which deals 99999 damage, is powered not only by the hero's Love Interest, but also the spirits of, who had just sacrificed themselves minutes earlier to give the previous "final boss" a body to kill.
 * An interesting variation occurs in Silent Hill 3, when Alessa,, manifests in the amusement park in an attempt to kill
 * Averted in the second No More Heroes game, where the #1 assassin presents Travis with the severed heads of Sylvia, Henry, and Shinobu on platters, only for Henry to come crashing through the window midway through the battle, telling Travis that they're fake.

Music

 * Alice Cooper has a song called I'm Alive (That Was The Day My Dead Pet Returned To Save My Life). Being Exactly What It Says on the Tin, it's full of examples. (Including rats... this is Alice Cooper.)