In Armada, Xavier Lightman does this no less than three times. Other characters such as Shin, Milo, Chen also do it.
In the Hurog duology, the enemies are in castle Hurog. There is no way to defeat them now, except ... making the castle collapse above them. As it is Powered by a Forsaken Child, this can be achieved by killing Oreg, who is magically bound to the castle. It is he who decides they must do it, as there is more at stake than just the ownership of the castle and surrounding lands.
Percy is initially thought to have killed himself to take out a ghost army that threatened Hazel and Frank. Then, after defeating Alcyoneus, they go back to the glacier only to find Percy there, totally unperturbed at bringing a glacier down on himself.
Played Straight in The Mark of Athena when Percy(he really does tend to do this often) throws himself down to Tartarus to protect Annabeth. And there are only a few thousand supercharged monsters in his path!
Leoin The Blood of Olympus dies while killing Gaea. He comes back from the dead later, though
Gandalf in The Lord of the Ringsdelays the Balrog, gets pulled into a nearly bottomless pit by its fiery whip, and then proceeds to fight it all the way up the Endless Stair, dying of his wounds and exhaustion after finally succeeding at the top of Celebdil. He is then brought back to life and becomes Gandalf the White.
The Silmarillion is full of these, being the darker of Tolkien's works. In no particular order, Finrod, Aredhel, the entire House of Hador, Glorfindel, Ecthelion, Beren and Lúthien all die doing something heroic (although the last two don't take).
At the end of the Chain of Dogs (a massive host of refugees marching across the continent) in Deadhouse Gates, the remnants of the Seventh Army and the Wickans sacrifice themselves in a Last Stand to delay Korbolo Dom's army until the refugees reach Aren.
In Toll the Hounds Anomander Rake sacrifices himself to get Mother Dark to return to her people. This is the equivalent of a religious leader sacrificing himself to bring back a god who abandoned people.
Also in Toll the Hounds and related to the above: Spinnock breaks down injured and exhausted when he feels Rake's death after stalling Kallor for a whole night for him. Averted in that Korlat sweeps in with a healing draught to tide him over until he can recuperate at home.
K'rul surrendered practically all his power when he cursed the tyrant king Kallor on Jacuruku. Interestingly, he originally planned to just stop Kallor with the help of his brethren, but when it became obvious that Kallor anticipated their arrival and dealt with his entire population the Caligula-way, he cursed him instead, unaware that the death of an entire population could power Kallor's retaliation well enough that he himself would be cursed to fade from public memory.
In Black Legion, Mekhari regains his memories for enough time to stand in the way of Horus' clone and take the blow that would otherwise kill Khayon.
In The Mirror Demon, out of all creatures, Bad Luck sacrifices itself to let Ida escape from Temper's world in the climax of the book. Epilogue reveals he survived, for better or worse.
Made especially tragic, as he was raised to believe that allowing oneself to become a supernatural creature is a Fate Worse Than Death, and, knowing this, Raze specifically forbids him from killing himself while making their deal.
In Girlfriend In A Coma by Douglas Coupland, Karen makes a sacrifice of sorts: she goes back into her coma at the end, so that her friends may have a second chance at life and the world will be restored to normal. Although Richard tries to stop her, she makes it clear that she's always known this will have to happen, and there is no way out.
At the climax of Honour Guard: Several Ghosts attempt to get an icon to where it will activate a weapon, knowing that the person doing it will die. Several suffer crippling injuries. Finally, Vamberfield does it as he saw in his vision, after suffering nine wounds as the martyr (whose icon it is) suffered, and dies.
In Traitor General, shortly after their meeting, Landerson tells Gaunt that the hounds have his scent and says he will lead them off; Gaunt dismisses this as a Stupid Sacrifice and saves him. He offers again, in the Untill, to carry the unconscious Feygor because it will not matter if he falls behind.
In Only In Death, when the Blood Pact are climbing a net of ropes, Gaunt, also on the net, cuts the ropes so they all plummet.
Necropolis has one that serves as the Crowning Moment of Awesome for a character who's been a pain in the neck for Gaunt and the other heroes, as Commissar Kowle, in the face of a Chaos Beast, allows the beast to bite off his own arms... which were holding a belt of grenades, which explode and kill the Chaos Beast, allowing Gaunt to reactivate the Shield.
Lasciel's Shadow ultimately turns to the side of good in the last moments of White Night, saving Harry's life by taking the psychic backlash of the spell she used to save him at the cost of her life.
In Death Masks, Shiro gives his own life up to replace Harry's in Nicodemus's plan. The suffering he went through before dying (and he was alive at the end, too) was described as being nothing short of profane, and to make things worse, he couldn't die of it until later, either.
In Aaron Dembski-Bowden's Warhammer 40,000 novel Void Stalker Mercutian, badly wounded fighting the Phoenix Lord Jain Zar, stays behind to buy his fellow Night Lords time to escape. Jain Zar demolishes him but leaves him to bleed out, which turns out to be a huge mistake giving Mercutian the opening to shiv her in the thigh. He is promptly executed, but his last act gave the other Night Lords a chance at victory.
Multiple ones turn up in the Ben Counter written Grey Knights trilogy, but a special mention has to go to Medic Haggard, who in a last act of defiance against a powerful daemon possessing his ship sends it hurtling into the presence of the daemon's patron god. What follows is a You Have Failed Me of biblical proportions, with Haggard laughing as the daemon screamed in fear.
In Lloyd Alexander's Black Cauldron, the titular cauldron can only be destroyed when someone willing enters the cauldron, fully aware that he will die. At the end, the Jerk Ass of the story redeems himself by jumping in.
It is a far, far better thing that I do, than I have ever done; it is to a far, far better rest that I go, than I have ever known.
Diane Duane's Young Wizards series takes it as a given that defeating the Lone Power will require someone making a Heroic Sacrifice. In particular, Deep Wizardry concerns one of the protagonists unintentionally signing away her life in payment for a previous act. Played even straighter when Ed, the Eldest Shark, willingly substitutes himself.
Also in Young Wizards, the avatar of a Power is taunted with the fact that to fully manifest, his passenger would have to kill the host and "he would never do that". The avatar promptly responds with "But I would", and throws a spear intended to be deflected so that it veers back around and hits him in the chest. He doesn't die, but the intention of a heroic sacrifice was there, and he comes close enough that the Power is released.
Diane Duane, again. In book 2 of her Trekverse Rihannsu series (The Romulan Way) Federation Ensign Luks rams his warp courier into a Romulan Warbird to allow the rebel Romulan cruiser Bloodwing to escape ch'Rihan orbit. In the backstory from the book, a Romulan who was secretly working with the Federation allows himself to be captured and executed; this has the effect of strengthening Terise Lo Brutto/Arrhae t'Llhweiir's cover (a Federation agent pretending to be a Romulan).
Rachel in Animorphs, who agrees to go on a suicide mission to kill Tom and destroy the Blade ship from within.
Turns into a Senseless Sacrifice when it's revealed that Erek drained the Pool ship's weapons, not wanting Jake to use them to kill. As a result, Rachel is unable to render the ship completely inoperable, and it escapes.
Tobias counts for this one right from the very first book, The Invasion. During the battle under the school, he chooses to attack one of the Hork-Bajir ready to infect Cassie with a Yeerk. This in turn leads to him ultimately being trapped as a Red-tailed Hawk, permanently. He gets better, though. Sorta. Although the characters begin to wonder if it was intentional.
Eponine in Les Misérables, kind of. She only gets shot to save him because she wanted to die first, she still wanted him to die though.
Madame Akkikuyu, the rat fortune-teller in Robin Jarvis's Deptford Mice trilogy. In volume one, The Dark Portal, she starts off as an unscrupulous trader who descends into fully-fledged villainy under the influence of Jupiter, rat god of the sewers, but demonstrates the possibility for redemption when she momentarily considers running away with Audrey instead of delivering her to Jupiter's altar. In volume two, The Crystal Prison, she has lost her memory and appears to have changed for the better in Fennywolde but is still unwittingly under the influence of Jupiter. She finally earns redemption at the last minute, when she recognises Jupiter and realises his evil plan, then throws herself into a fire to save Alison Sedge, the mouselet she was supposed to sacrifice, and prevent Jupiter's return to life. She also inadvertently starts a massive fire in Fennywolde and unwittingly completes Jupiter's spell anyway, so her sacrifice is all the more tragic in that she earned personal redemption but failed to hold Jupiter back.
In Nightbringer, Virgil Ortega and his fellow Arbites seize the armory and rig it to explode, to keep it from the hands of the rebels, without regard for the danger. Even when it becomes clear that it will cost all of them their lives.
In Dead Sky Black Sun, Leonid, having persuaded Uriel to leave him behind because he is dying, explodes a grenade, taking out monsters that could have chased the escaping Marines.
The climax of Garth Nix's Old Kingdom. To bind Orannis, Lirael goes in assuming that she will die, as symbolised by her ringing of the bell Astarael. Then the Disreputable Dog bites off her hand to save her and sacrifices her own life instead.
Every single Dzur in any of Brust's Dragaera books will insist to be the one making any heroic sacrifices required, despite the fact that none have actually become necessary. (No, Zivra/Zerika jumping off Deathsgate Falls does not count as a heroic sacrifice.)
In the Final Battle of Song of the Lioness by Tamora Pierce, Liam Ironarm for all his shang-dragon-ness realizes that he can't catch eight arrows at once and takes them to save Jonathan's life. Later the Shang Wildcat delivers a letter to Alanna, written by Liam before the last battle, which confirms that his death had been foretold.
Additionally: James & Lily Potter, Dumbledore, Snape, Neville, Hagrid, Regulus Black, Wormtail (okay, maybe not quite that heroic), and everyone who fought in the Battle of Hogwarts. Not all of them were deaths, though.
In The Bartimaeus Trilogy, Nathaniel, the main character, dies in the final pages of the book while defeating an evil spirit. He dismisses Bartimaeus and sacrifices himself.
In James Swallow's Warhammer 40,000 novel Faith & Fire, Iona takes up the mask of Repentia, because honorable death is her only good fate, and it spares the rest of her squad.
In Gav Thorpe's Warhammer 40,000 novel Angels of Darkness, the Dark Angels are in a fortress where a virus is free. Boreas convinces them that their duty is to remain there and die, because their suits cannot preserve their lives longer than the virus can last, rather than unleash it on the world. Fearing what they might do when desperate, they commit suicide together.
The sacrifice of the HMS Thunderchild in HG Wells' The War of the Worlds. In a Crowning Moment of Awesome the torpedo ram destroys two Martian vessels at the cost of itself and her crew, allowing a fleet of refugee vessels to escape. Although London has fallen to the Martians, this victory and the ambush and destruction of a Martian tripod by a hidden artillery battery at Shepparton show that they're not invincible.
Played straight in the Ea Cycle with the Heroic Sacrifice of Alphanderry. Subverted in the case of Bemossad whose death turns out to be pointless and counter-effective for the most part and the benefit to the heroes, such as it is, comes in a way he didn't intend.
Sturm Brightblade, a Knight in Shining Armor indeed, even if he wasn't one officially through most of his life, performed one in the second Dragonlance novel, giving the other heroes a chance to activate the Lost Superweapon and giving the Knighthood an example to strive for, pulling them from their slide into corruption.
It may be that she was just an old, mad, half-blind and technically evil dragon and only a supporting character anyway — but without Matafleur's last flight to protect 'her' children from Highlord Verminaard and his dragon mount, the attempt to free the prisoners at Pax Tharkas would have ended in fire and blood thanks to Eben's treachery and the whole original trilogy might well have ended then and there (which is to say, with the first book).
In the Stuart Slade-authored novel The Salvation War: Armageddon, in the last chapter before the epiloguea number of (dead) Romans who were enslaved by the demons of Hell are rescued by U.S. Marines in 2008 — but when the Marines' sergeant is about to walk into a tripwire for a rock trap, the dead Simplicus without thinking pushes him backward, inadvertently hits the tripwire himself, is crushed and dies a second time. Despite being dead to begin with, it's a Heroic Sacrifice because nobody knows if humans get another extra life.
Mildly subverts the trope in that the heroic sacrifice is not intentional, and in the original thread where this story was posted there was actually a discussion before the chapter about such.
In the novelization of Revenge of the Sith, the dragon lizard that Obi-Wan rode on Utapau, named Boga, somehow sensed the clone attack coming and twisted herself in midair to take the brunt of the blasts, saving Obi-Wan's life.
Jangotat of The Cestus Deception, a Star Wars Expanded Universe novel, is a clone who has just been given the knowledge that his life has meaning - he's an individual person, he can love - he then calls down an orbital strike on his own position to save millions, leaving a final loving message recorded for the woman who taught him he could be more.
Outbound Flight. Jedi Knight Lorana Jinzler and Syndic Mitth'ras'safis (older brother of the more famous Mitth'raw'nuruodo), in order to land the dying vessel in such a way that the last fifty-seven survivors won't be killed, had to spin the entire thing around so the side they are in is crushed into the planetoid. They aren't very happy about this, and each suggests that the other move and save themself, but they both know it will take two to pull it off, and they take it calmly. Unfortunately, the abridged audiobook cuts out this scene, so those who have only listened to it will never know about this.
Thrass: "It appears we will both be dying to save your people."
In the Star WarsExpanded Universe book "Vector Prime", Chewbacca sacrifices himself while saving Han Solo's son. A gravitational weapon has pulled a backwater planet's moon out of orbit, and it's slowly falling towards the planet. Han, Chewie and Anakin Solo are busy loading the Falcon with refugees. But as Anakin is heading back to the Falcon, a chunk of debris cracks the back of his head and he goes down. Chewbacca notices and runs back to rescue Anakin. With the Falcon as packed as it is and the wind getting more turbulent, Chewie chooses to throw Anakin up to the people crowded on the landing ramp. The Falcon takes off because there's no more room for Chewie, and he dies roaring in defiance at the moon.
Later on in the same series of books, Anakin Solo (not to be confused with his whiny namesake, whom he is exponentially cooler than) is heading a mission with Jedi infiltrators to kill the source of a weapon that's slaughtering the Jedi. Partway through, he sustains a nasty injury to his side, which only gets worse because they're never able to stop, make camp and let him heal. As his condition becomes critical and the team is trapped in a small building, Anakin takes a high powered blaster and his lightsaber, tells the others he's going to give them an opening to escape, and charges out to face a group of warriors that rival Darth Maul in viciousness. The fight scene that follows is one of the most badass in all Star Wars. Also a Tear Jerker moment when he promises his girlfriend that he'll come back to see her, and it's clearly obvious (at least to the readers, if not the characters) that he won't.
Ganner Rhysode's Crowning Moment of Awesome when he agrees to defend a gateway to the World Brain in order to give Jacen Solo time to put his plan into motion. Over a thousand warriors, each capable of killing a Jedi in a fair fight, versus one mediocre Jedi. The resulting carnage was so incredible, Ganner was made an impassable GOD in the Yuuzhan Vong pantheon after building a literal rampart of dead enemies before succumbing to a Death of a Thousand Cuts
His last act before death is to use the Force to collapse the building they're in, killing all the remaining Vong in the process.
Halo: The Fall of Reach: The orbital drydock Cradle moves to absorb the Covenant fire and protect the human ships. Every single human who saw this was stunned by it. Earlier, a wounded Sam stays aboard a Covenant ship to both buy John and Kelly time to escape, and to ensure a bomb goes off inside the ship's reactor.
Halo: The Flood: McKay blows up the Truth and Reconciliation while still inside it in order to prevent the Flood aboard from potentially escaping.
In Halo: First Strike, Haverson and Whitcomb use themselves as bait in order to lure a 500-strong Covenant fleet towards a space station that's been set to explode; the two are able to take almost the entire fleet with them to the grave.
Kurt also goes out with a literal bang in Halo: Ghosts of Onyx - badly wounded, he stays behind and delays a Covenant army as the rest of the cast escape through the slipspace portal. He then sets off a dozen nukes, taking the Covenant with him and simultaneously generating both the book's biggest Crowning Moment of Awesome and Tear Jerker moment. Just before that, he updates his status to MIA, which is standard for all Spartans.
Halo: The Cole Protocol: Juliana, who's already at death's door due to her rampancy, stays behind to personally crash the Rubble into a Covenant base in order to cover the Exodus Project's escape.
In the second novel David Weber's Hell's Gate series, Prince Janaki uses his precognitive abilities to successfully defend a fort from enemy attack - despite the fact that the strength and clarity of his vision means that he will die during the battle.
Also the historical Emperor Halian who died leading his army in defense of one of his ally's cities.
In Edgar Rice Burroughs's The Gods of Mars, Thuvia attempts to let John Carter escape by sliding from his mount, thus lessening the burden. He thinks that she does not know him well enough to think he would accept it — but it is Cathoris who actually rescues her, and Carter admires his son, even though his self-sacrifice would prevent their escape.
Later, when Phaidor, a Woman Scorned, goes to stab Dejah Thoris, Thuvia throws herself between them. That girl's got a real death wish going. Fortunately she gets over it.
King Haarahld at the end of Off Armageddon Reef: needing their victory to be as complete as possible, he tried to intercept the last of their enemy fleet only for the enemy flagship's crew to board the King's in a suicide attack. Haarahld ended up fighting alongside an eleven-year-old midshipman, who threw himself between his king and an attacker with an arbalest. Immediately upon realizing what the boy was doing, Haarahld threw him aside and took the arabalest bolt in his leg, ultimately causing him to die of blood loss. This act, combined with his last words and his gallantry at sea, make King Haarahld a hero among his people.
The sacrifice of the original Nimue Alban. Nimue knowingly volunteered for what was a hopeless suicide battle not only to help get the last survivors of humanity to safety, but also to enact The Plan to ensure its success.
A non-fatal version in Annals of The Black Company: The Lady chooses to give up her powers and live as a mortal rather than allow an even greater evil than herself to take over the world.
In the Dale Brown novel Flight of the Old Dog, Dave Luger leaves the Old Dog to fight off Soviets who are threatening his comrades.
Fatal Terrain, Brad Elliott crashes the EB-52 Megafortress with himself on board into a Chinese ICBM site.
In Battle Born, Rinc Seaver deliberately "de-stealths" his modified B-1B to draw missiles to it instead of the missile aimed at the enemy HQ. Subverted because he was going to eject, until the plasma-yield warhead on his missile takes him.
Throughout the The Power of Five series, Richard does this for Matt no less than three times. And despite trapping himself in a collapsing museum with animate dinosaur skeletons so Matt could get out, being taken by "kidnappers" while allowing Matt the time he needed to get safely away, and emptying a gun into a ship's entire load of fireworks so Matt and co could escape without notice, he is still alive. Go figure.
The Dragon Reborn is fated to spill his blood in the final battle in order to save the world. Though his blood is spilled, he procures a backup body and is ultimately saved. The mental preparation for this Heroic Sacrifice contribute in large part to his descent into insanity over the course of the series.
In the finale, Egwene figures out how to counter the damage of Balefire, but dies in the process of weaving that spell. She later berates the Dragon Reborn in his battle with the Dark One for assuming that only he was allowed to sacrifice himself. He'd been carrying the weight of that assumption throughout the entire series, that not only was he the leader but that he was the sacrificial lamb, and that any other deaths were a failing on his part.
Lan nearly pulls this off taking down one of the Forsaken, but he's saved at the last minute.
Mat gives one eye to save Moiraine. The effects of that decision almost certainly saved the entire world in the beginning of the last book.
Lightsong is particularly impressive because he actually pulls this off twice.
In the Dark Reflections Trilogy, the flowing queen must return to her body (leaving her host, Merle) in order to defeat the Big Bad. but to do so, the life energy of her host must be exchanged with the life energy of her own body—and her body has none. Merle is willing to die to save the world/her friends, but the flowing queen speaks through her, telling all Merle's friends and her Love Interest that someone could, in theory, take Merle's place. Merle refuses to let anyone, but Serefin pleads with her. She says no, but the Queen agrees that it would work. Serafin kisses Merle, taking the Queen's spirit into him, and then makes the transfer.
Empire from the Ashes has many heroic sacrifices, starting with Dahak's original captain in the prologue. In the second book, Dahak reveals his ability to defy his core programming (and thus the direct orders of his captain) just so he can pull off a sacrifice himself (he gets better).
Juliet Marillier's "Blade of Fortriu" has a magnificent example. Deord volunteers to be the bait for the hunting group that is after Faolan and Ana. In the end, he dies after killing many soldiers, several hunting hounds, being castrated, hit by twelve arrows, and still lingering there for five or six hours without complaining. The only thing he asked for was for Faolan to sing in his last moments. And he just barely knew the people he saved.
In the second book of Taylor Anderson's Destroyermen series, some of the people they're trying to help attempt to sink USS Walker with an improvised bomb in a rowboat. CPO Donaghey climbs into the boat and rows it away, ignoring the calls of his shipmates to come back. Instead of a fuse, the saboteurs set the whole boat on fire, so he's burning alive as he does this.
All he knew, as the flesh on his face and hands began to sear and his vision became a red, shimmering fog, was that he had to row. Nothing else in the entire world mattered anymore except for getting that crazy, stupid bomb the hell away from his ship. He made it almost forty yards.
In a later book, everyone's favorite "Super-Bosun" Fitzhugh Gray pushes his captain out of the way of an incoming rush of Grik. His body is later recovered from under the pile of dead Grik, some of them by his own hand.
In the Back Story of John C. Wright's The Golden Age, Helion had sacrificed himself in a solar storm, especially to save his son. During the course of the novel, Phaethon believes that the whole civilization lies in danger, and opens his memories, knowing it will mean exile.
In The Phoenix Exultant, Atkins asks whether Phaethon is willing to die to save the Golden Oecumene, Phaethon says it goes without saying, and Atkins says that it's because the two of them are the only ones to say it, nowadays.
In The Golden Transcedence, Atkins reveals that the Sophotechs who had died in the solar storm had actually realized they had been affected by a virus and committed suicide rather than spread it.
In the Legends of Dune prequel trilogy, Xavier Harkonnen pilots his ship into a star in order to kill Grant Patriarch Iblis Ginjo who knowingly allowed the Tlulaxa to harvest organs from living people and who was becoming more and more Stalin-like in his policies. Slightly subverted in that Xavier knew that the moment he found out the truth, his life was forfeit, so he really had nothing to lose.
Unfortunately, for his trouble, Xavier was branded a traitor, and the truth never came to light.
Also, the reprogrammed mech Chirox is attacked by a former student who joined the cult of machine haters. After reluctantly killing the student, Chirox realizes that his other students will die to protect him from an angry mob and shuts himself down. This is the only case in the novels of a machine sacrificing itself for a human.
Quentin Butler helps Vorian Atreides kill the last three Titans, knowing full well that he will die the instant the last Titan falls. However, by that point, he was no longer human and did not consider his continued existence "living".
Each Guardian is a human who gave up their life to protect someone else from supernatural forces, and received the Call to Adventure at the moment of their death.
Lawrence Huff's Dome novel, about a runaway nuclear reactor. Extreme sportsman and metallurgist Dan Mason dons a protective suit and attempts to plant control rods in the malfunctioning reactor core. Unfortunately the reactor environment is far more hostile than expected and his suit is critically damaged, while the magnetic field set up by eddies in the coolant is causing the suit to electrocute him. Though he is in a haze of agony, he prevents a complete meltdown (which would destroy Louisiana and possibly push the Earth out of orbit) by drawing the control rods from the suit's pouch, shoving his arms directly into the superheated core and planting his legs over the drain holes to disrupt the eddies. He succeeds. His body is never found.
Two characters sacrifice themselves in the Legacy of the Drow Series. Wulfgar, in the grip of a monster that is threatening his friends, causes an avalanche that buries them both. Shortly afterwards, Drizzt attempts a heroic sacrifice after concluding that his presence in Mithral Hall is putting those around him in danger from future drow attacks targeting him. He decides to leave and return to Menzoberranzan, allowing the drow to have him in order to spare those dear to him. After he's taken captive, however, Drizzt learns that the drow are intent on attacking Mithral Hall whether he's there or not, and that turning himself in didn't accomplish anything.
Drizzt tries one in Paths Of Darkness while bleeding out from Le'lorinel's potion. The companions can only save one of the two, so he tells them to save Le'lorinel, whom he recognized as the elven child he rescued on his surface raid in Homeland. Naturally, his friends will hear nothing of it and save him, damning Le'lorinel to bleed out.
Fablehaven has Lena, a naiad turned human, sacrifice herself to stop the shadow plague by destroying the talisman infused with dark energy.
In The Farthest Shore, Ged uses all his power to close the hole in the world. He doesn't die, but he does permanently lose his magic (he describes it as pouring a cup of water on the ground), so the person he was is essentially dead.
Vanyel Ashkevron of Mercedes Lackey's Heralds of Valdemar. Facing his greatest fear, one that has been hounding him since childhood, he calls down a Final Strike killing himself and his enemy and saving the kingdom.
In the final book of the His Dark Materials trilogy, Lord Asriel and Marisa Coulter willingly consign themselves to the Abyss by dragging down Metatron with them in order to save the world and give their daughter a chance to live
But they had their own selfish reasons and little else to live for, too. Infinitely more heroic was the death of Lee Scoresby. Seriously, that man died holding off an enemy force by himself just to buy a girl he barely knew the time to continue her ungraspable quest to do not-even-she-knew-what. And then gave his body as a final sacrifice to feed Iorek Byrnison, the sentient armor-wearing bear who had been his friend. If there's a more tearjerker set of scenes in YA lit, it's been hidden well away.
In the The Black Magician Trilogy Akkarin gives Sonea all his power and refuses to let her heal him in order to prevent the Ichani from destroying the guild.
Bess in the poem "The Highwayman" by Alfred Noyes. She is taken prisoner by the British Army troops who want to capture her lover the highwayman. They tie her up and bind a loaded musket to her with the mouth of the barrel against her chest. When the highwayman arrives she pulls the musket's trigger, killing herself and warning the highwayman to flee.
In Catching Fire by Suzanne Collins, first Mags, then the unnamed Morphling addict from District 6 give up their lives to save Peeta, which confuses Katniss greatly.
Katniss herself in the first book when she takes Prim's place at the reaping.
Peeta does it for Katniss, more than once.
Alien by Igor' Dravin (Чужак, Игорь Дравин): Vlad's unit grabbed the Wolves (5 female Hunters) and his sister Dunya from the altars of a Human Sacrifice ritual disrupting it and killing several Catacomb Lords. Nata, a healer mage, is the only one conscious among the saved and knows that Arna, the Wolves' commander, Dunya and herself can yet be saved if exorcized in time. Seeing a group of religious fanatics intercept Vlad's unit demanding the survivors to be burned at stakes, Nata calmly burns her magic gift to make sure Vlad's beloved Arna and Dunya survive long enough for Vlad's unit to kill the ambushing troops and reach the city, knowing well that this dooms herself.
Subverted in Chalice by Robin McKinley. The Fisher King of the demesne of Willowlands is all set to throw himself on his challenger's sword during their Trial by Combat, in the hopes that his voluntary sacrifice will keep the land from tearing itself apart during the transition to a new (and foreign) Master. However, Mirasol and her enormous swarm of bees object very strenuously his plan.
Bes in Riordan's other series The Kane Chronicles pays his "ren," or true name, to the moon god Khonsu in a game of senet in order to buy Sadie and Carter more time in the Duat to revive Ra. Because of this, at the end of the second book he becomes a mindless husk stripped of his memories. His memory is restored in the final book, though.
Ricard de Laal in Helm, when he discovers what Siegfried Montrose is doing.
When a bounty is placed on all Jedi by Yuuzhan-Vong warmaster Tsavong Lah, Dorsk 82 is trapped on Ando by a mob of scared Aqualish. Most of the galaxy is afraid that if they don't immediately turn in or kill all Jedi, the Yuuzhan Vong will target their world next. Escape is highly unlikely, and if he did manage to he would have to kill many Aqualish. He decides that his life is not more valuable than all of theirs, and is gunned down while taking no defensive action.
Mundo Cani in The Book of the Dun Cow succeeds in blinding Wyrm and trapping the monster underneath the earth, but at the price of his own life, since he is sealed underground forever, too.
Trapped on Draconica. After transforming into Mordak, Kalak kills himself to prevent himself from killing Daniar.
Robert A. Heinlein's short story "The Green Hills of Earth". While "Blind" Rhysling is a passenger on a spaceship, he goes to the power room to visit with the Chief Jetman, an old friend of his. A sudden blast of radiation from the reactor kills his friend and endangers the ship. Instead of fleeing, Rhysling repairs the damaged reactor while taking a lethal dose of radiation, thus saving the ship, the crew and the passengers at the cost of his own life.
Dragontales, a collection of Dungeons & Dragons-related stories. In "The Wizards Are Dying", a cleric named Diehm goes into the area where the godling lich Xanthak had been imprisoned in order to lure the lich inside. Once he does so, his friends close the door and seal it again, leaving him trapped inside with an angry, insanely powerful monster. His friends hope he dies quickly.
From It comes Reginald "Belch" Huggins. Even though he's been a bullying Jerk Ass for most of the book, Belch actually redeems himself when he protects Henry from It after the monster kills Victor and goes after Henry. Unfortunately for him, he gets half of his face torn off for his trouble.
Kraken gives several examples. Dane Parnell dies heroically, playing it straight. Billy Harrow has someone teleport him in a way that causes suicide and immediate recreation elsewhere—a Billy lives on, but not the one who has been the protagonist so far. And played most strangely with the Architeuthis that gives its name to the title. Despite being a dead specimen of a giant squid in a museum, it gives up ever having existed to foil Vardy's plan.
In The Host Melanie attempts suicide in order to prevent the hosts from using her memories. Wanderer attempts suicide, but the others intervene at the last second.
In Andre Norton's Forerunner Foray, Turan sacrifices the last of his strength to pull Ziantha out of D'Eyree's mind. When she returns to her own time, she can't find his mind. Later she learned that his body is still alive but his mind had not returned. With Harath's help, she saves him.
Madison in The Leonard Regime veers her damaged plane into that of an enemy plane, saving everyone below from an air strike. Also played to a lesser but still significant scale when Sam takes a bullet for Nick.
In The Testament Of Jessie Lamb, the sixteen year old protagonist decides to sacrifice herself by giving birth to a child, in a world where a disease kills every pregnant woman, but certain drugs can keep the body alive until the end of pregnancy. As a vaccine has been found with which frozen fetuses can be vaccinated, her child, if a girl, might be able to give birth without dying from it, but it is far from certain. Jessie's name is most likely no coincidence.
The Castellan, who transmits the codes needed to escape Gallifrey to the Doctor, despite knowing he'll probably get executed for this. Karlax suspects he was responsible and tells Rassilon he'll find out who did this.
The Jacob's Ladder Trilogy features two notable ones. In the backstory, Hero Ng sacrificed his life to stop a reactor coolant leak caused by the Breaking. In the main story, Rien sacrifices herself to unite the Angels into a new worldsoul at the climax of Dust.
A species-wide example in The History of the Galaxy books, as discovered by the archaeologists about a race of Precursors dubbed Delphons. They were Fish People who lived 3 million years ago and had even managed to establish outposts as far as Earth. When they detected the Forerunner swarm, moving from system to system, guided by starlight, consuming all matter in their path (except the stars themselves). None of the four races living in that area of space (Delphons, Harammins, Insects, and Logrians) had developed a portable hyperdrive, relying instead on a Portal Network that required portals to be first towed to the destination at sublight. Unlike the other three races, who chose to run and hide from the swarm, the Delphons decided to stay and fight, using the only way they knew how - Star Killing. The only weapons they had in their arsenal that could harm the animal-like clumps of proto-matter were their own stars. So, they waited for the swarm to approach each star in their system, and then used a device that caused the star to go nova. They kept doing this until the swarm was wiped out, but so were the Delphons, although they did that knowing that they were allowing other life-bearing worlds in the path of the swarm to survive (including our very own planet).
In Mikhail Akhmanov's Invasion, Space Navy fighter pilot Lieutenant Commander Pavel Litvin, captured earlier in the novel by the Faata, witnesses the Curb-Stomp Battle that wipes out a huge chunk of Earth's nascent Space Navy. After the huge alien starship lands in the Antarctic, a Metamorph who has been secretly living on Earth for nearly a millennium teleports aboard and provides Litvin with the means to end the threat, while also leaving a largely intact ship for human scientists to study and reverse-engineer. The catch is, Litvin himself would die from the same thing that would kill off the crew. A true Space Marine, Litvin agrees without a second thought, activating the Grey Goo device programmed to eat the ship's organic brain (which would shut off Artificial Gravity and Reinforce Field). However, the mysterious alien manages to teleport Litvin out safely, something he claims earlier he can't do.
Cole towards the end of Forever injects himself with his personally created serum shifting himself into his wolf form so that he may fight off Shelby giving Sam enough time to escape and lead the pack to safety from the aerial hunt, causing himself to end up getting shot after killing Shelby. He manages to survive though - just barely.
The Burning of the Rice Fields is a classic traditional Japanese story, where an old rice farmer upon a tall hill suddenly saw something alarming out at sea and ordered his son to help him burn his rice fields. When the villagers nearer to the shore saw the fire, they all ran up the hill to confront him about this senseless act of destruction. At that, the old man pointed out to the sea and there was a giant tsunami coming right at the village. The village is devastated, but the old man sacrificed his crop to lure his neighbors to safety.
In Ancillary Justice, Breq jumps down a bridge to save Seivarden, who has fallen down there a moment ago and is clinging to a very fragile piece of glass. Breq is wearing very efficient armour and counts on possibly surviving, but the fall does break every bone in her body.
In Honor Harrington, Andrew LaFollet, one of Honor's Grayson Armsmen, manages to save Honor's son and mother during a Colony Drop by ejecting them from an aircar moments before the blast wave reaches the vehicle. He tries to save himself after that, but doesn't make it. Many of Honor's other Armsmen die protecting her, as befits a true Grayson Armsman. One even willingly throws himself into an exposed corridor, using the moment of stunned disbelief (no sane person would expose himself so) to spray the heavily-armed Havenites with a Flechette Storm before they recover and shred him with the same. All Armsmen are trained to do this for their Steadholders without hesitation, and only the best get the job.
In StarCraft: Speed of Darkness, the remaining Space Marines willingly activate the psi-emitter to lure the Zerg to their bunker in order to buy precious time for the shuttles sent by the Sons of Korhal to evacuate Mar Sara City (as shown in the game). None of the marines survive.
In The Traitor Son Cycle, Prudentia sacrifices herself to provide the Red Knight with enough power (drawn from her soul) to let him fight Thorn on even terms.
The Horatio Hornblower novel Ship of the Line ends with Hornblower taking the Sutherland into a battle against four French ones, because the rest of his squadron is becalmed and he can't allow the French to break the blockade. He knows it's a doomed battle, but he manages to cripple all but one of the French before he is finally forced to surrender with his ship sinking from under him, half his crew dead (including the Plucky Middie he'd grown fond of) and his Number Two, Bush, losing his foot.
Words of Radiance (second book of The Stormlight Archive): Kaladin attempts one to prevent Elkohar from dying at Moash's hands. This ends up being just what Kaladin needs to redeem himself and regain his powers, so he survives.
In Warrior Cats, when badgers attack Thunderclan's camp, Cinderpelt, a Medicine Cat with a crippled leg, fights a badger one on one to protect the newborn kittens and their equally defenseless birthing mother in the nursery. While the badger ends up killing her, she delays it long enough for 2 Warriors to arrive and drive it away.
The reason Cal works for the Daemon is because he made a deal to save his grandfather's life.
James literally gives up his heart, which kills him, so Dee can be free from her contract and live a normal life.
In The Divine Comedy, all the brave who died in war or the good who martyred for God live in the fifth sphere of Heaven, Mars. Instead of worshipping the god of war, these fallen soldiers take joy not in battle or blood, but in the beauty of the Cross, which they sing the praise of while assembling themselves in the shape of that holy weapon upon which God died.