Hogwarts was founded circa the 10th century, by two wizards and two witches: Godric Gryffindor, Salazar Slytherin, Rowena Ravenclaw, and Helga Hufflepuff. They each represented an aspect of wizarding that they wanted to bring out in new students. However, shortly after founding Hogwarts, Salazar Slytherin had a falling out with the other founders. Slytherin wanted to admit only pure-blood students, but the other three founders disagreed. Slytherin left the school, but not before secretly building the Chamber of Secrets. When his own true heir, the Heir of Slytherin, returned to the school, he or she would be able to open the Chamber, unleash a horrible Basilisk, and purge the school of all Muggle-born students.
About three hundred years after the school was founded, the Triwizard Tournament began between the three most prestigious magical schools in Europe: Hogwarts, Beauxbatons, and Durmstrang. This Tournament was considered the best way for wizards of different nationalities to meet and socialize. The Tournament continued for six centuries, until the death toll became too high, and the Tournament was discontinued.
The existence of the school was threatened twice when the Chamber of Secrets was opened. The first time it was opened was in 1942, when Tom Riddle, the Heir of Slytherin and the man who would become Lord Voldemort, opened the Chamber in his fifth year. When a girl named Myrtle was killed, the Ministry of Magic threatened to close the school. As Riddle spent his time away from Hogwarts in a Muggle orphanage, he did not want the school closed, so he framed Rubeus Hagrid and dodged his crimes for decades.
In 1992, the Chamber was re-opened by Ginny Weasley, under the influence of a diary written by Riddle. The diary allowed Riddle's memory to possess Ginny, allowing him to act through her to open the Chamber a second time. Lucius Malfoy, through the desire to further the power of the Dark Arts, had slipped the diary into her bundle of schoolbooks, with the hope that she would be possessed and carry out the necessary work for Lord Voldemort. His ulterior motive was to ruin the reputations of several great wizards, including Albus Dumbledore and Arthur Weasley, the latter of whom was highly influential concerning the Muggle Protection Act. However, Harry Potter discovered the truth, destroyed the diary and the Basilisk, thus bringing an end to this dark plots.
In 1994, the Triwizard Tournament recommenced with more powerful safety measures in place. However, more dark plots were being hatched. Barty Crouch Jr., disguised as Professor Alastor Moody, managed to enter Harry in the Tournament by putting his name in the Goblet of Fire under the name of a fourth school, which ensured he would be chosen by the Goblet. Harry's involvement in this plan caused him great misery at Hogwarts, as the representatives for Beauxbatons and Durmstrang, as well as many Hogwarts students, believed he was a cheater. It was because of Crouch Jr. and his influence over certain house-elves that Harry ended up at the end of the tournament with Cedric Diggory in a graveyard surrounded by Death Eaters. Voldemort was brought back to his physical form using Harry's blood in a complex spell. He attempted to torture and humiliate Harry, but Harry escaped and succeeded in alerting all Voldemort's enemies that he had returned. However, to the horror of all at Hogwarts, Cedric Diggory was murdered at the whim of Voldemort.
Hogwarts was further threatened when the Ministry of Magic began implementing "Educational Decrees" in 1995, as part of a conspiracy to discredit and ruin Albus Dumbledore. Dolores Umbridge, the new Defence Against the Dark Arts teacher, was the centre of this plan. With these Educational Decrees, she slowly took control of Hogwarts, and eventually replaced Albus Dumbledore as Headmistress. But it was through the cunning of Hermione Granger and the members of Dumbledore's Army that Umbridge was overthrown. The Ministry had no choice but to accept that Voldemort had returned. Order was restored to Hogwarts.
In 1997, Hogwarts was attacked by a mob of Death Eaters. Student Draco Malfoy was seduced into the service of Lord Voldemort with the promise of fame and glory. As a result, Headmaster Albus Dumbledore's safety was compromised, and he was murdered by Severus Snape. Following this horrible tragedy, Professor Minerva McGonagall was appointed acting Headmistress, although the security of the school hung by a thread. There was no certainty that Hogwarts would remain open. The faculty agreed to follow "established procedures" and let the school governors ultimately decide.
Regardless of the school governors' decision, with the takeover of the Ministry by Voldemort, attendance at Hogwarts was mandatory for all eligible children. New, militaristic requirements were established, such as proof of blood status. Muggle Studies, involving mainly of how muggles are vile things, became a required subject. Severus Snape was appointed Headmaster. It was a time of great terror in which no one could be certain who was friend or foe.
In May of that year, 1998 the Battle of Hogwarts took place. This battle ended with the death of many on both sides. Voldemort fled, but Harry potter died in the battle.
Hogwarts fell under ministry control many yearsafter the battle of Hogwarts. The headmaster, Kingsley shacklebolt jr., has managed to keep Hogwarts safe from the ongoing war beween the order and the death eaters.