Harris County Judge Ed Emmett proposes turning Houston's Astrodome into the world's largest indoor park at a press conference in 2014.Pat Sullivan / AP

Senator Ted Cruz may have survived a spirited challenge from Beto O’Rourke, but straight-ticket voting by Democrats in the high-turnout election almost certainly enabled a 27-year-old graduate student with no government experience to topple the highly respected moderate Republican who has for the past decade led Harris County, Texas, the third-largest county in America.

Lina Hidalgo’s 1.5 percent win over Ed Emmett stunned the local political establishment and highlighted both the potency of anti–Donald Trump sentiment in greater Houston and the changing demographics of the region. The county, which covers virtually all of Houston, has 4.7 million residents, with large numbers of whites, blacks, Hispanics, and Asians.

All of Texas’s major cities—Houston, San Antonio, Dallas, Austin, and O’Rourke’s hometown of El Paso—are liberal, Democratic, and heavily diverse. They also happen to be where most of the state’s breakneck growth is taking place.

Hidalgo will be the first woman, Hispanic, and immigrant to lead Harris County, where a plurality of residents are Latino and about a quarter are immigrants. She has only lived in the area for a total of seven years, has never managed a large organization, and has never attended a meeting of the powerful county council she will soon lead. The Houston Chronicle’s editorial board endorsed Emmett with its highest possible rating, calling him experienced and moderate. The paper’s preelection profile of Hidalgo said she faced an uphill battle against “possibly the most popular local figure who did not win the World Series last year.”

Even Julián Castro, the best-known Texas Democrat after O’Rourke, told The Atlantic this week that the incumbent “had a strong reputation as being bipartisan.” Emmett supported expanding Medicaid in the state and led the charge for a $2.5 billion bond measure that slightly increased property taxes to pay for flood-control efforts. He was endorsed by a longtime Houston Democratic state representative and he endorsed the Democrat challenging Dan Patrick, the GOP lieutenant governor adored by the Tea Party who got his start as a talk-show host in the Houston area.

Voters rejected Emmett along with every other county-level Republican, electing Hidalgo as well as a judicial candidate who didn’t appear to be running a formal campaign and who previously faced charges of dating violence. The Chronicle editorialized, “Our zeal to throw out the bums cost us some of our best servants.”

Among Hidalgo’s first words in an interview Wednesday: “It wasn’t an accident.” She was pushing back on arguments that she only won because anti-Trump sentiment led to record turnout and spurred Democratic straight-ticket voting. This was the last year with that option for Texas voters, as the GOP-controlled legislature joined other states in ending a practice that ignores individual candidates’ record or qualifications. According to the county clerk—another Republican who lost a reelection bid—Democrats saw a lead of more than 100,000 ballots among straight-ticket voters. Hidalgo won the election by fewer than 18,000 votes.

“For us, it’s going away one election too late,” lamented Vlad Davidiuk, the spokesman for the county’s Republican Party. Even the day after the election, he blasted Hidalgo as “absolutely and indisputably unqualified for this position … There was no appeal to Lina Hidalgo’s qualities or qualifications. She has none. It’s completely a fluke.”

Many people inside and outside Texas scratch their head at the title of “county judge”; it’s the county government’s executive officer. Only in sparsely populated counties do county judges still maintain any sort of a judicial role. The Harris County judge oversees a $3.7 billion budget and nearly 17,000 county employees with responsibilities ranging from law enforcement to hospitals to road construction to flood control.

“This is the most powerful office [in Texas] outside of a statewide office,” said Castro, who served as President Barack Obama’s housing-and-urban-development secretary and as San Antonio’s mayor. Texas political scientists say that’s a fair assessment, perhaps tied with the mayor of Houston. But they say Hidalgo can’t take much credit for winning the post.

“It’s effectively straight-ticket voting, pure and simple,” said Mark Jones, a Rice University political scientist and a leading expert on Texas politics. “It wasn’t about her. She was elected because of straight-ticket Democratic votes, which were fueled largely by a strong Democratic-turnout machine, opposition to Donald Trump, and Beto O’Rourke’s appeal. And she didn’t do anything to disqualify herself … At the margins, being a Latina tends to be slightly positive. But by and large, the Democratic Party won that election, not Lina Hidalgo.”

That’s how Emmett portrayed it in his post-concession tweets. (His spokesman said he wasn’t doing interviews.) “Keeping the straight ticket option for 1 more election cycle turned out to be a disaster for all Republicans,” he wrote. “Making up that deficit was just not possible. I am proud of my campaign since I received significantly more votes than any other Republican, including those at the top of the ticket.”

Another political scientist pointed to Hidalgo’s language about “recovery for all” after last year’s devastating Hurricane Harvey and her representational appeal in a diverse county whose Republican leaders have been overwhelmingly older, male, and white. “There was some draw to Hidalgo as the first Latina county judge running on a campaign of Democrats really targeting Latinos to try to get out the vote,” said Emily Farris, a Texas Christian University professor of urban and racial/ethnic politics. But she also said the victory owed a lot to overall Democratic turnout and straight-ticket voting.

Hidalgo had asked voters to set aside her youth and inexperience, instead campaigning on the values she would represent. “The most important qualification for this office is not 40 years in politics,” she said in an interview Wednesday. “That didn’t work. We need a strong moral compass.” While Emmett was lauded for his steady hand leading the county through frequent flooding and two major hurricanes—even though he had suffered a minor stroke just days before Harvey—she criticized him as only showing up “when it’s raining outside.”

Her lack of familiarity with the nuts and bolts of county government shone through. In the Chronicle’s side-by-side editorial-board interview of Hidalgo and Emmett, she could not name the county auditor when challenged to do so, and she said the county’s flood-control authority should publish online maps so residents can check whether they live in a floodplain (it already does that).

She said she’s spoken with Emmett since the election and plans to keep in touch. She promised that she’s building “a team that includes people from across the political spectrum, from across the community, from across sectors.” When asked how she would work with the entirely Republican set of statewide leaders, she said she would build relationships with the county’s bipartisan delegation in the legislature.

But Hidalgo clearly does not want to be a subdued centrist like Emmett. She told The Atlantic that she sees her election as a chance to speak for Texas progressives on national issues, opposing Trump-administration policies when she sees them affecting Harris County. “Part of the opportunity I want to take is to take a stand,” she said Wednesday. In terms of population, “we’re larger than 26 states. On all sorts of issues, we have to make our voice heard.”

Hidalgo’s election showed a historically purple county looking more and more solidly blue. And across deep-red Texas, where Republicans have won every statewide race since 1994, there were hopeful signs for Democrats. Cruz kept his Senate seat, but O’Rourke was only two and a half percentage points behind him, while Cruz’s 2012 victory came with a margin of 16 percent.

Hidalgo’s win and the massive Democratic turnout are encouraging signs for Castro, who’s mulling a run for president in 2020. (He said he’ll make a final decision by the end of the year.) On Wednesday, he said, “What happened in Texas last night, in Harris County and statewide, convinces me that Texas’ 38 electoral votes will be in play in 2020.”

We want to hear what you think about this article. Submit a letter to the editor or write to letters@theatlantic.com.