The X-Men have fought against the humans that hate and fear them for a long time, and they have faced a number of near-miss extermination events over the past few decades that have drastically reduced the mutant population. Several different forces have almost brought an end to mutantkind, from robotic Sentinels to diseases like the Legacy Virus.
While most existential threats to the X-Men come from humans or other mutants, one of the worst the team has ever dealt with came from the Inhumans, a group of people that the X-Men once considered friends. Tragically, the cause of the mutant plague that affected the X-Men came from an event that mutants themselves had very little involvement in. However, the Inhumans' use of a Terrigen Bomb still unleashed the M-Pox virus, which killed several major mutants an kicked off a war.
During the Infinity crossover, Thanos led an invasion on Earth to search for his offspring. While most of Earth's heroes were in space, Thanos demanded a tribute from the Inhumans of the heads of all Inhumans between a certain age range, which was to cover the fact that Thanos was hoping to kill a specific Inhuman, his son Thane. This brings Black Bolt, leader of the Inhumans into direct battle with Thanos, which forces him to use a deadly Inhuman weapon, the Terrigen Bomb.
The Terrigen Bomb was built by Black Bolt's brother, Maximus the Mad and required Black Bolt's powerful voice to detonate, which would then spread the Inhuman's Terrigen Mists into the atmosphere and across the planet.
The Terrigen Mists came from Terrigen Crystals that were used to activate the Inhuman gene, which was initially the result of experimentation on humans by the alien Kree. When Black Bolt detonated the Terrigen Bomb, the Mists dispersed throughout the atmosphere and caused thousands of new Inhumans to undergo Terrigenesis.
Unfortunately, the Terrigen Mists reacted with the Earth's atmosphere in an unforeseen way that proved to be deadly to the mutant population. When readers first learned about M-Pox mutantkind had been dealing with the outbreak for a few months.
M-Pox was a degenerative disease that affected every mutant differently depending on how it reacted to their particular mutant biology. Some mutants died upon first contact with M-Pox while others slowly succumbed to the effects of the disease.
While there were a number of "unknown" mutants who died due to the M-Pox, there were a few big-name X-Men who also lost their battle with M-Pox. Some of the X-Men who contracted M-Pox were Rogue, Sunspot, Dazzler and the young mutant Goldballs. The X-Men were forced to retreat from their home to the Limbo dimension where they established X-Haven.
Death of X revealed some of the earliest casualties of the plague were numerous duplicates of Jamie Madrox, the Multiple Man, who had been investigating the illness that had wiped out every other mutant on Muir Island. When the X-Men investigated his distress signal, he revealed the threat of the Mists before he died. Unfortunately, he also infected Cyclops with M-Pox, who died upon first contact with the plague.
X-Men VS Inhumans
Unbeknownst to the rest of the X-Men, Emma hid the true nature of Scott's death and began to use a mental projection of him to lead the X-Men while they dealt with the remains of the Terrigen Mists. The Mists had formed into two deadly clouds that were sweeping the globe before they completely mixed with the atmosphere, rendering Earth uninhabitable for mutantkind. Emma had her Cyclops lead the X-Men into battle against the Inhuman Royal Family and destroy one of the clouds using a mutant named Alchemy to change it's composition. However, he died from M-Pox due to his exposure.
Emma was able to frame Black Bolt for the death of Cyclops, which lead to an all-out war between the Inhumans and the X-Men. Forge was eventually able to create a device that would neutralize the Terrigen Mist, which the Inhuman Queen Medusa activated herself to destroy the cloud when she realized the ultimate threat it posed to mutantkind. Emma's schemes were revealed and a tenuous peace fell between the X-Men and the Inhumans after the destruction of the Terrigen Clouds. The M-Pox disappeared without the clouds to fuel it, though the mutant plague had taken a costly toll.