These days, pants are our garment of choice. But for years, our ancestors draped themselves in tunics, robes, and gowns, until someone decided they were tired of having the wind up their skirt. So, what prompted the change? When, exactly, did two-legged trousers become a thing?

A recent archaeological discovery gives us a clue. Archaeologists Ulrike Beck and Mayke Wagner of the German Archaeological Institute in Berlin excavated two ancient graves in a cemetery in Xinjiang, China and, among the remains, discovered two pairs of well-preserved woolen pants. Radiocarbon dating puts them at between 3000 and 3300 years old, making them the oldest-known pair of trousers ever discovered. This historical time period corresponds with the rise of “mobile pastoralism” in Central Asia—nomads began moving their herds across the land, and they did so on horseback. Tunics and robes weren’t comfortable or conducive to long, bumpy rides—and battles—so these ancient people innovated. They created pants.

“The invention of bifurcated lower body garments is related to the new epoch of horseback riding, mounted warfare and greater mobility,” Beck and Wagner write in a recent paper outlining their findings. They believe the pants, which are straight-fitting and have a wide crotch suitable for straddling, are predecessors to the riding trousers worn today. Along with the pants, the graves also contained horse-riding gear like bridles, whips, and horse tail.

Victor Mair, a professor of Chinese language and literature at the Center for East Asian Studies, believes the nomads of the Tarim Basin, located in the Xinjiang region where the pants were found, started riding horses about 3400 years ago. Mair himself helped identify what were previously thought to be the oldest pair of trousers, found on a 2600-year-old mummy in the same area.