Texas Lt. Gov. David Dewhurst, above, will head into a July 31 runoff election against former state solicitor general Ted Cruz for the Republican nomination to the U.S. Senate. (Pat Sullivan/AP)

In the latest pitched fight of the GOP establishment against the party’s conservative base, Texas Lt. Gov. David Dewhurst couldn’t knock out a challenge Tuesday from former state solicitor general Ted Cruz for the Republican nomination to the U.S. Senate.

Dewhurst, after serving a decade in the powerful state post, entered the race a prohibitive favorite to win the nomination and succeed retiring Sen. Kay Bailey Hutchison (R), but he saw his share of the vote slip in the final weeks of the campaign below the 50 percent mark. He now heads into a July 31 runoff election against Cruz — a new favorite of the tea party movement — in what analysts say will be a toss-up contest, given the expected low turnout.

With nearly all of the ballots counted, Dewhurst had 44.6 percent to Cruz’s 34.3 percent; several other contestants divided up the remaining votes.

The Senate race was the marquee event, but Texas hosted a collection of other contests pitting grass-roots candidates against establishment figures, a recurrent theme of primary races in both parties as congressional approval ratings sit at an all-time low.

Rep. Silvestre Reyes, an eight-term Democrat, faced an upstart challenge from Robert “Beto” O’Rourke, a former El Paso City Council member, while Rep. Ralph M. Hall, a Republican from northeast Texas, fought off a pair of opponents.

When all ballots were finally counted, just before midnight Tuesday, O’Rourke had defeated Reyes by winning 50.5 percent, clearing the 50 percent threshold by little more than 200 votes and thus avoiding a run-off election. Reyes finished with 44.3 percent of the vote.

Reyes and Hall were targets of an anti-incumbent super PAC, the Campaign for Primary Accountability, which spent more than $400,000 in the final two weeks against the lawmakers.

The Texas primary took place nearly three months after its originally scheduled date, the result of legal challenges to the redrawing of district lines. Such challenges have become a tradition in the state’s messy redistricting process.

A federal court rejected the Texas Legislature’s first map and drew up its own, only to have the Supreme Court order it to more closely hew to the legislative map in crafting interim districts. The districts could be altered again next year as the legislature and state officials consider implementing a final map.

Other key contests in the state included one in the huge district running west of San Antonio to El Paso, pitting former congressman Ciro Rodriguez against state Rep. Pete Gallego for the Democratic nomination. Rodriguez and Gallego are now headed for a run-off, as the former congressman finished with 46 percent and the state legislator with 41 percent.

The winner will face Rep. Francisco R. Canseco (R), who ousted Rodriguez in 2010, in what will be the most one of the most hotly contested general-election matchups anywhere in the country.

And in a new district that runs from Austin north to Fort Worth, former Texas railroad commissioner Michael Williams failed in his bid to secure the GOP nomination and become the state’s first African American Republican in Congress, finishing a distant fifth place with 10.5 percent of the vote. Instead, former Perry administration official Roger Williams will face Wes Riddle, a former Army lieutenant colonel and defense contractor, in the July runoff.

So far this year, four House incumbents have lost their primary bids. Two of them, one Republican and one Democrat, were beaten by challengers, while two others lost in primaries in which redistricting forced them to run against other incumbents.

The most heated race has been the Reyes-O’Rourke battle, in which the 39-year-old challenger has raised nearly $400,000 in his bid to unseat Reyes, a former chairman of the House Intelligence Committee. O’Rourke has aired commercials accusing Reyes of helping a firm win a contract for border security after that company hired the lawmaker’s children.

“A huge no-bid contract for a politically connected firm who hires the congressman’s children,” the O’Rourke ad trumpets to the sound of a typewriter tapping out the news. “Who is Silvestre Reyes really working for?”

The incumbent’s campaign, in turn, has accused O’Rourke of turning “his back on the disabled community” for voting, while on the city council, to cut housing funds for the disabled.

Reyes has also touted the endorsement of former president Bill Clinton, who stumped for the incumbent in El Paso in late April before 3,700 people.

“I believe in sticking with your friends and being loyal to people who have helped you,” Clinton told the crowd.