When I moved to Washington, D.C., a few years ago, I needed to buy a bed. The salesman at the mattress store warned me to choose carefully. We spend a third of our lives sleeping, he told me, so picking a mattress was one of the most important decisions in life (somewhere in the top ten, he said). I didn’t go for the ultra-fancy, super-expensive mattress set he recommended, but my bed is far more luxurious than the world’s oldest-known mattress: layers of leaves and grass.

This 77,000-year-old mattress was discovered in the Sibudu rock shelter in South Africa, a few miles from the Indian Ocean. Reporting in the journal Science, Lyn Wadley of the University of the Witwatersrand and colleagues say the three-foot-by-six-foot mattress, what they call bedding, consisted of compacted layers, less than an inch thick, and was probably used as both a sleeping and a work surface. The mattress also came with built-in pest controls: In addition to grasses and sedges, it was made from the stems and leaves of a type of laurel tree known as Cryptocarya woodii, whose aromatic leaves contain insecticides that kill mosquitoes.

Given the age of the mattress and other artifacts at the site, it’s clear that Homo sapiens was the hominid who slept in the cave. The earliest hominids had very different sleeping accommodations. They probably settled in trees at night. Even though they had evolved an efficient way to walk on the ground, hominids such as Australopithecus were still small, not much bigger than a chimpanzee. If they slept on the ground, they would have been vulnerable to nocturnal predators looking for a midnight meal. Sleeping in trees is how many primates avoid nighttime enemies. The fossils of early hominids indicate this was possible; they still retained features useful for climbing, such as curved fingers and long arms. Once in the trees, they likely built nests of branches, twigs and leaves, just as chimpanzees do today.

The first hominid to try the ground as a bed might have been Homo erectus, starting at 1.89 million years ago. The ability to control fire may have made this shift to the ground possible, argues Richard Wrangham, a biological anthropologist at Harvard University. In his book Catching Fire: How Cooking Made Us Human, he suggests that once hominids learned how to control fire they discovered they could sleep on the ground while the flames kept predators away. Fire was also useful for cooking and processing foods, allowing Homo erectus to expand its diet. Foods from trees may have been less vital, as was sleeping in the tree tops. Adaptations for tree climbing were eventually lost, and Homo erectus became bigger and taller, the first hominid with a more modern body plan.

There’s no evidence in the paleontological record that hints at what type of bedding or ground nest Homo erectus used. But modern humans were certainly not the only hominids to construct “mattresses.” Neanderthals were also building grass beds, based on evidence from a cave site in Spain dating to between 53,000 and 39,000 years ago. Since then, beds have undergone a rapid evolution of their own, from grass mattresses to futons to waterbeds. If you’re interested in the more recent history of where we sleep, consider reading book Warm & Snug: The History of the Bed by Lawrence Wright.