AUSTIN, Texas (AP) — Beto O'Rourke didn't turn Texas blue. But for the first time in decades, it's looking much less red.

The midterm elections in Texas ousted a Republican who carried a "bathroom bill" targeting transgender people, drove out a GOP lawmaker who called federal immigration agents on Hispanic protesters and gave Democrats in Houston run of the nation's third most populous county.

For a generation, Texas has been a laboratory of conservatism that tested legal boundaries and churned out Republican presidential candidates. But cracks in the GOP's supremacy emerged this week in unexpected ways and races. As with many things Texas, the results could reverberate nationally.

Predictions that Texas will come into play in 2020 may still be a stretch, but the signs of a subtle shift are more than mere talk.

"This is the most optimistic I've felt since high school," said Dallas state Rep. Eric Johnson, a 43-year-old Democrat who is running to become the first black speaker of the Texas House. "I know for a fact that Texas is a purple state. It hasn't been voting that way because Democrats have forgotten how to win, to a certain degree. But Beto has reminded us."

He was unequivocal about why Democrats broke through this year.

"Beto was the reason," he said.

It remains to be seen what's next for O'Rourke, who came within 3 percentage points of Republican Sen. Ted Cruz in the closest Senate race in Texas in 40 years. The El Paso congressman, who shattered fundraising records in a Senate campaign, raising more than $70 million, has insisted he's not interested in another office for now. But that has done little to dampen speculation that he could run again in 2020.

Texas' other Senate seat, held by Republican John Cornyn, is up for re-election that year. He called the midterms a "wake-up call" for his party in Texas.

"I don't know whether this is a once-in-a- lifetime confluence of events or whether this represents something of the new normal," said Cornyn, the second-ranking Republican in the Senate.

On the surface, Texas didn't change much after Tuesday. Republicans continued a 24-year streak of sweeping statewide races and lost only two seats in Congress, both of which had already been trending toward Democrats. The GOP also still comfortably controls the Texas Legislature, even after losing a dozen seats in what was the biggest single-year pickup by Democrats in decades.

But Republicans' big margins shrank in a number of places.

Typically easy wins in five congressional districts around Austin, Dallas and Houston were sliced to within 5 percentage points this time. The driving social conservative force in the Legislature, Lt. Gov. Dan Patrick, won just over 51 percent of the vote in his first election since pushing a failed North Carolina-style "bathroom bill" that would have required transgender people to use public bathrooms that correspond with the sex on their birth certificate. Not surviving, however, was a Republican who carried the bill in the House.

Texas' last big Republican county, around Fort Worth, also crumbled at the top of the ticket. Fort Worth is "Cowtown," with stockyards and a cowboy image that stands in contrast to Texas' other big and increasingly liberal cities. Of Texas' five largest counties — the others around Dallas, Houston, San Antonio and Austin — Tarrant County was the only one President Donald Trump carried in 2016, doing so by 57,000 votes.

Two years later, O'Rourke won the county over Cruz by 3,900 votes.

"We flipped this state from blue to red. We may be shifting back a little toward the blue," Tarrant County Republican Party Chairman Darl Easton said. "But political shifts happen. I'm not overly concerned about the current trend."

Fast-growing suburbs that for years have served as a GOP firewall to Texas' liberal big cities also either flipped to Democrats or were winnowed down to single-digit races. It was an abrupt turnaround from just four years ago, when Republicans coasted into every statewide office with 20-point victories.

The gap drastically shrunk on the coattails of a Democrat whose support for universal health care, marijuana legalization and immigration reform was mocked by Republicans as anathema to voters who've kept the GOP in control of Texas since 1994.

After his loss, O'Rourke urged others to pick up where he left off.

"This team, of which we are all members, in some way is going to stay together, is going to continue to aspire to do great things," O'Rourke said. "There are so many great candidates who are going to come out of this campaign."

___

Follow Paul J. Weber on Twitter: www.twitter.com/pauljweber

___

For AP's complete coverage of the U.S. midterm elections: http://apne.ws/APPolitics .

Copyright 2018 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.