LAURENS, Iowa — Pocahontas is running out of students. Public school enrollment in this corn-blanketed county in northern Iowa has plummeted 32 percent over the past decade as the population steadily shrinks. Schools have merged, classes have combined, and sports teams have consolidated, wiping out generations of tradition and rivalry.

As Joe Kramer, a school superintendent in the county, sifted through the cruel math of his latest casualty (a girls’ varsity basketball program), he wore the weary look of an overbooked funeral director.

“It’s a struggle for a community to make decisions like this,” he said. “It’s so much a part of our identity.”

Two hours south, Dallas County faces a very different problem: It is running out of schools. With the population swelling, in what used to be farmland ringing Des Moines, enrollment in its largest district has doubled over the same 10 years. As soon as a gleaming new high school is completed, construction on another begins.

The hard conversations here, said Dave J. Wilkerson, the local superintendent, are telling parents that their children’s schools have become overcrowded.

“I apologize that we will have to send your children off to a new, state-of-the-art school,” he said. “I would rather be dealing with this challenge than with what Pocahontas has.”

Iowa, the quintessence of heartland America, is undergoing an economic transformation that is challenging its rural character — and, inevitably, its political order.

As Iowans prepare to elect a new United States senator for the first time in three decades, the scale at which people and power have shifted from its rural towns to its urban areas is emerging as a potent but unpredictable undercurrent in the excruciatingly close race, offering opportunity and risk for both sides.

The state’s once ubiquitous farms are supporting fewer workers, the towns built around them are hemorrhaging younger residents, and a way of life eroding for decades is approaching a denouement. Farm fields are yielding to the new headquarters of banks, insurance companies and health care providers, whose rapid expansion is luring waves of Iowans to cities and suburbs, and contributing to the state’s enviable 4.5 percent unemployment rate.