During the time of the Black Death in the 14th century, plague was believed to be caused and spread by miasmas — unhealthy, disease-carrying smells and vapors from either the corpses of those who died by the disease or from the breath of those infected. Throughout the centuries, plague has been considered God's punishment for sins, and it's also been blamed on astrological and natural phenomena, such as comets and earthquakes. And to treat it, people have tried aromatic vapors from flowers and herbs, such as rose and thyme, as well as amulets and magical remedies. They've asked patron saints for help and tried to purge their sins through self-flagellation and prayers.
The real causative agent of the plague wasn't discovered until 1894, during the third worldwide pandemic, when bacteriologist Alexandre Yersin identified the bacterium Yersinia Pestis. Today we know that Y. pestis can infect different parts of the body, resulting in three types of plague: bubonic (infecting the lymphatic system), pneumonic (infecting the lungs) and septicemic (infecting the blood).
Yersin also discovered that rat fleas — specifically the Oriental or Indian rat flea Xenopsylla cheopis, and the Northern or European rat flea Nosopsyllus fasciatus — were the primary carriers and spreaders (called primary vectors) of the bacterium during the pandemic. The human flea, Pulex irritans, along with the dog and cat fleas, Ctenocephalides canis and Ctenocephalides felis, were secondary vectors. It's theorized that gerbils may have been responsible for introducing plague-carrying fleas on trade routes from China.
Bubonic and septicemic types of plague spread through flea bites from infected fleas or, though more rarely, through bites from an infected animal, such as a rat or gerbil. Pneumonic plague, however, is directly spread through infected droplets from sneezing and coughing.
While infected fleas are known vectors of Y. pestis, it's Y. pestis itself that gave rise to the possibility of plague. The bacterium was originally a gastrointestinal pathogen, but researchers discovered in 2015 that during its evolution, the bacterium underwent two genetic changes that transformed it from a mild stomach bug to a pandemic-causing plague agent. In its first evolution, it acquired through a single gene the ability to produce a protein that gave it the ability to infect the lungs. Through a single genetic mutation of that acquired gene, Y. pestis next evolved the ability to infect the blood and the lymphatic system.