The Goblin Invasion of Hogwarts occured in June of 2010, in the story Hogwarts Houses Divided.
The invasion was the result of centuries of discord between wizards and goblins, centering primarily on the refusal of wizards to allow goblins to own and use wands. In the years leading up to the invasion, a contingent of goblins armed themselves with goblin-made blades as well as Muggle explosives and firearms, along with constructing a vast underground network of tunnels that led beneath Hogwarts Castle.
The invasion itself was led by Slipfang, who had been sneaking into Hogwarts Castle since September of the previous year to steal the wands of several students, including Alduin Beauxjour, Ellie Cattermole, and Stephen White. In preparations for the full-scale invasion, Slipfang recruited the House-elves of Hogwarts to his cause, enslaving them to his own will by unknown magic. Through them, he poisoned most of the students and staff of the school with a Sleeping Draught, which struck during breakfast and rendered the majority of the wizards unconscious in the Great Hall. His army then flooded the Hall and retrieved the wands of every student and teacher, after which his troops rounded up hostages and led them back to their House dormitories to search for goblin-made artifacts.
Unbeknownst to Slipfang, Teddy Lupin, Kai Chang and Gilbert Zirkle escaped to the Astronomy Tower with a bicycle that had been smuggled into the Castle and enchanted as part of a D.A. protest. Professor Sinistra offered the use of her broom, and Lupin, Chang, and Zirkle took off from the top of the Tower to find help. Lupin, however, doubled around the Castle and returned to Gryffindor Tower, where he managed to overpower the goblin Grimnail and impersonate him, releasing Colin Hayes, Alfred Cattermole, Edan Burns and Judith Woodbury from Orghawk, Klewscour, and Ragnok the Younger.
Lupin then headed for the kitchens, but was detoured to the Great Hall by Nearly-Headless Nick, and ran across the House-elves Golly, Teazle, Griffy and Lolo, whom he tricked into freedom by taking the form of Slipfang. They attacked him until he revealed his true identity, at which point Ophilia Karait, at the Slytherin table, stood to reveal that she had feigned her unconsciousness. Using the Marauder's Map, Lupin and Karait discovered that Hugh Truncher and the Slytherin Quidditch team was being held captive at the Quidditch pitch, and Karait persuaded Lupin to lend her the Map and his wand so that she could rescue them with Professor Sinistra's help.
After learning of Beauxjours' murder, Lupin took the form of a goblin again and descended into the dungeons, finding the blast-hole and the wall of ANFO. Golly Apparated him past the blockade, and he descended into the tunnels.
White, Violet Parkinson, and Nagaeena Indrani were led to the Slytherin dorms, where White tricked the goblin Tuk into turning his back. White pushed Parkinson and Indrani to the floor as he cast a solaplaster spell to stick Tuk to the floor, and a deprimo spell that shattered the ceiling-window and let the water from the Lake rush into the dorm. White pulled both girls out of the dorm in time to force the door closed and hold back the Lake, then led them past the blast-hole and through the Castle until they reached a heavy wooden door that White blasted open. The three fled the Castle past the greenhouses and ran for the Forbidden Forest with goblins in pursuit.
After breaking from Lupin, Chang and Zirkle headed for Hogsmeade to find the town burning, and turned back for Hogwarts Castle. On returning, they were flagged down by Burns and Woodbury in Gryffindor Tower, and landed to pick up the students. As they attempted to flee again, they spotted White, Parkinson and Indrani fleeing the Castle, and dove in to rescue them, pulling them onto the bicycle and broom under a volley of crossbow bolts and bullets before taking off again and crossing the Black Lake to the far side of the campus. When they landed again, Zirkle realized that Chang had been struck through the thigh by a bullet, and Zirkle heaved him onto the bicycle, taking off again for the Muggle town of Muirmouth.
Parkinson, Indrani and White waited on the hillside until they saw explosions on the Quidditch pitch. Moments later, Professor Sinistra, Karait, Truncher, Jonathan Madscarf and the Slytherin Quidditch team flew over the Lake and picked up the first-years, heading back to the Castle with them. Parkinson demanded the Marauder's Map from Karait, and Karait relinquished it.
Beauxjour, Dewey Diggory, Sung-Hee Moon, and Mercy Burbage were led to the Hufflepuff dorms, where several goblin-made items were found. Beauxjour called one his captors, the goblin Bagrim, "vermin," and was subsequently shot in the chest and killed for the insult. Diggory, Moon and Burbage were then led to the dungeons and through the blast-hole into the tunnels below, where they were united with Chloe Grey, and the four were locked in a holding cell with the Sorting Hat, which had been taken in an attempt to discern the whereabouts of Gryffindor's Sword. Grey managed to draw the Sword from the Hat and free herself, Diggory, Moon and Burbage from their bindings before Bagrim returned to the cell; she then stabbed Bagrim, killing him, and Diggory took his firearm before leading the students into the tunnels.
Diggory, Moon, Burbage and Grey were reunited with Lupin and Golly, who had Apparated past the ANFO wall, and Golly Apparated back to the Great Hall to find Teazle, Griffy and Lolo. The three elves then Apparated back to the tunnels without Golly, and Apparated Diggory, Moon and Burbage back to the Great Hall moments before Lupin, still in his goblin form, and Grey were discovered by goblins in the tunnel. The two Gryffindors were taken to Slipfang's underground command station, where they found Deana Forte, Aisha Allouzi, and Connor and Colleen McCormack. Lupin saved Grey's life by trading the Sword of Gryffindor to Slipfang, and discovered a guarded tunnel stocked with explosives and gunpowder. He managed to persuade Tyrus the Foul to help him rescue the children, then attempted to create a diversion by taking on Slipfang's form and transporting a bowlful of cooking coals to the gunpowder tunnel.
His ruse was discovered soon after he left the coals next to a gunpowder barrel when he attacked Slipfang, who was preparing to behead Forte, but the gunpowder ignited before Slipfang could attack. Grey, Allouzi and the McCormacks were secreted to the surface by Tyrus and a small contingent of goblins. Lupin was pulled to safety by the House-elf Moogums, who Apparated back to find the rest of the hostages, and Lupin found Forte being pursued by goblins. He transformed into a werewolf to drive them off, then led Forte through the darkness of the tunnels until the two found the ghost of Beauxjour, who led them to the surface, which emptied into the Forbidden Forest.
Moments after Diggory, Moon and Burbage Apparated back to the Great Hall with Teazle, Griffy and Lolo, a team of Aurors – including McIlvernock, Lydia Davis, Ronald Irvine, Erin Roberts, Roger Jones, Calliope Young, Hume MacDougal, Ron Weasley, and Harry Potter – arrived at the Castle. The Aurors discovered the ANFO wall in the tunnel below the dungeons, and Potter ordered an evacuation of the students and staff, an effort that was forceably aided by Karait, Truncher, Madscarf and the Slytherin Quidditch team as they returned from the Black Lake.
Potter learned from Dedalus Diggle that ANFO can be defused with moisture, and he and Weasley headed to the dungeons to open the Slytherin dorm only enough to allow the water from the Black Lake to slowly flood the tunnel and soak the explosives. Unfortunately, Peeves took it upon himself to force the door completely open; Potter and Weasley fled the Castle, which had by then been evacuated, moments before the ANFO detonated with significantly less force than it may have otherwise.
Potter then retrieved the Marauder's Map from Parkinson, and used it to locate Lupin in the tunnels below the Forbidden Forest. He, Weasley, Young, Davis, Irvine, Roberts, and MacDougal flew over the Forest until they found the area where the Map claimed Lupin was, at which point they were nearly knocked from the air by the force of the explosion that Lupin had caused in Slipfang's command station. Karait and Truncher arrived moments before Potter and his Aurors found Lupin and Forte on the ground, and Potter ordered the Slytherins to take the first-years back to the Castle The Aurors then located Allouzi, Grey, and the McCormack surrounded by a hoard of acromantula, and Potter conjured a Basilisk to fend them off.
Karait and Truncher defied orders and followed the Aurors as goblins soon launched an attack from the ground, initiating a fierce skirmish. Young was killed in the fighting, and Slipfang managed to stab Grey with the Sword of Gryffindor before the Aurors converged on him and killed him with half a dozen simultaneous curses. Weasley Apparated Grey to St. Mungo's where she astoundingly recovered, though she lost the ability to perform magic entirely.
Draco Malfoy arrived at Hogwarts following the evacuation with enough Rejuvenating Potion to wake the staff and oldest students.