If you want to sell clothes in America, it helps a lot if buyers think your product is cool. Jeans have a backstory that any marketer would kill for. “Denim first became popular in the 1920s and 1930s in tandem with the rise of Hollywood,” explains Emma McClendon, an associate curator at the Museum at the Fashion Institute of Technology, who orchestrated a denim retrospective at the museum in 2015. “That positioned jeans as the uniform of the lone cowboy, synonymous with the romance and promise of the American West.”

Over the years, the cuts and washes changed, but denim’s position as a relatively democratic element of the wardrobes of stylish, influential people didn’t. Bell-bottoms ruled the late ’60s and ’70s. Acid wash and tapered legs took over in the 1980s. Looser, higher-rise mom and dad jeans were part of millions of outfits in the ’90s, a decade capped by several years of angsty skater teens embracing enormous JNCOs. In the 2000s, celebrities took “low rise” and “skinny” to their logical extremes.

Then, for a moment, denim fell off. The jeans popular during the 2000s were uncomfortable and difficult to wear for the hundreds of millions of Americans without pop-star bodies. Cool jeans also suddenly became quite expensive. New designer brands such as Seven for All Mankind and Citizens of Humanity boosted prices well over $150, which made it harder than ever for people to feel like they could be on equal fashion footing with the celebrities whose looks they wanted to emulate.

By the end of the decade, people were ready for something different, and “athleisure”—leggings, joggers, and yoga pants—swooped in. Leggings were far more comfortable than the super-tight jeans of the previous decade. They arrived as much of America was casualizing quickly enough to accommodate stretchy pants in social life and some workplaces. People began searching for yoga pants in earnest in late 2011, and American denim sales began to decline within a year or so.

Read: The mystery of business casual

But the singular reign of leggings was short-lived. After a few years, people seemed to realize that maybe thin elastic pants aren’t perfect for all occasions. Usually clothing trends as big as athleisure maintain their dominance for at least a decade, but black leggings only allow for so many looks. Jeans were poised to strike back. “The increased popularity of denim is a reaction to the dominance of the leggings and yoga pants of athleisure,” McClendon says. Last year, for the first time in half a decade, sales of denim increased.

Leggings are a perfectly reasonable way to clothe the lower half of your body, but in situations where you want to wear an outfit instead of just put on some clothes, they don’t provide much personality. That’s where jeans excel. Jonathan Cheung, Levi’s senior vice president of design innovation, credits Rihanna, along with other mega-famous creatives including Beyoncé, Kanye West, and the Off-White founder and Louis Vuitton designer Virgil Abloh, with helping turn the attention of fashion’s early adopters back toward denim. They did it by mixing often-inexpensive vintage jeans with luxury goods.