Here’s one thing we know: People get older. Another is that people’s tolerance for entry-level jobs and small urban apartments is highest when they are young adults. So while many things affect the increasing popularity of city living, including lower crime rates and a preference for walkable neighborhoods, one of the biggest factors is simply the number of people who are around 25.

Right now, that number is as high as it has been in decades. Another big driver of urban demand, immigration (both documented and undocumented), has been roughly constant since 2000. That number could change with policy, but given the current political climate, immigration seems unlikely to go up.

The last time the nation had a huge bubble of 25-year-olds was the late 1970s and early 1980s. Then, like now, an influx of people in their early 20s moved into cities. There were newspaper articles about young professionals gentrifying urban neighborhoods; “Changing San Francisco Is Foreseen as a Haven for Wealthy and Childless,” a New York Times headline said in 1981.

Each era has its economic challenges, and many millennials had the misfortune of entering adulthood during the Great Recession and its aftermath. The people at the tail end of Generation X, who came after the baby boomers, were born in the low-birth years of the late 1970s and entered adulthood during the late 1990s financial boom.

But the bulk of millennials came of age when jobs were scarce, Mr. Myers noted. They started moving into cities and apartments during years when rent was historically high. The number of young professionals was rising, adding to apartment demand, but supply was tight because new construction stalled during the recession. When city populations started swelling in the early and mid-2000s, it had less to do with the first of the millennials moving in than it did with lots of slightly older people not moving out, according to Kenneth Johnson, a demographer at the Carsey School of Public Policy at the University of New Hampshire.

The presence of so many young college graduates upended many American cities. You can see it in the hordes of techies congregating on weekends at Dolores Park in San Francisco and in the battles over gentrification. It’s behind new demands for rent control and the artists who live in cheap but unsafe warehouses.

In many cities, the high cost of living has galvanized a generation of young renters who have started to form a “YIMBY Party” that wants more apartment construction, and often pits younger renters against older homeowners.