Updated at 11:15 p.m. with O'Rourke concession, and at 10:45 with comments from Cruz campaign manager.

HOUSTON — The nail-biter Senate race in Texas ended Tuesday night with narrow victory for Sen. Ted Cruz, as Texans delivered their verdict on a provocative president and one of his key allies, a senator who vowed six years ago to disrupt Washington.

"Tonight is a victory for the people of Texas," Cruz declared. "This election was a battle of ideas. ... The people of Texas rendered a verdict that we want a future with more jobs, and more security, and more freedom."

Democrats nationwide invested their hopes — and $70 million — in Rep. Beto O’Rourke, an affable, charismatic and obscure three-term congressman from El Paso when he launched his bid.

Cruz, by contrast, had run for president and had a national profile, after forcing a government shutdown and staging a 25-hour talkathon early in his Senate term.

"He poured his heart into this campaign," Cruz said of O'Rourke, offering conciliatory words that some of his supporters in Houston met with boos. "Millions across this state were inspired by his campaign. They didn't prevail and I am grateful the people of Texas chose a different path. I am your senator as well. My responsibility is to represent every Texan."

And, he added, "I give you my word I will always fight for your jobs, for your security, for your freedom. ... That applies to everyone in the great state of Texas."

In El Paso, more than an hour later, O'Rourke said he'd congratulated Cruz and offered help "at this time of division ... this bitterness that defines so much of the national conversation today."

And he hinted that the movement he created won't dissipate.

"I'm so [expletive] proud of you guys," O'Rourke told the crowd. "This team, of which we are all members, is going to stay together, is going to continue to aspire to do great things."

O'Rourke raised more than any Senate candidate in history, which means he also spent more than any losing Senate candidate in history.

The contest had implications far beyond Texas. Views on President Donald Trump weighed heavily on the minds of voters, and Trump drew a crowd of 16,000 in Houston at Cruz’s biggest rally.

Democrats haven’t won a statewide office since 1994, and O'Rourke was by far their best bet in a generation to snap that streak. Republicans dread the day they lose Texas as a bulwark in presidential contests. With New York and California, Texas would give Democrats a near insurmountable edge in Electoral College math.

Interest in the Senate contest drove high turnout, including a surge in voters under 30 and Hispanic voters put off by the Cruz-Trump hard line on family separation and the migrant caravan from Central America.

The same issues galvanized support for Cruz, whose backers readily chanted “build the wall!” at his rallies and welcomed the president's vow to repel the caravan with troops.

O’Rourke was the first Democrat in a generation to harness enough support, and money, to force a competitive race. He filled a 7,500-seat baseball stadium with expectant El Pasoans on Tuesday night, and Democrats lauded him for an upbeat approach and unmatched mobilization.

With nearly half the state's voters aligned against him, Cruz will face a choice between sticking to his ideals and a style that generally does not include bipartisanship, or adjusting. Democrats are skeptical.

"You can't engage that many people, raise that much money ... without taking away some lessons," Cruz campaign manager Jeff Roe said. "Ted is a champion for conservative causes. He's a champion in Texas and he's a champion nationally. So I don't think you should look for him to start straying from his principles. But he is a person that's seeking common ground, and in a divided Congress, which it looks like we might get, there's going to be a whole bellyful of that coming up. And Washington will have to learn to work together."

At the Cruz election night party at the Hilton Post Oak in Houston’s tony Galleria neighborhood, several hundred supporters snacked on hamburger sliders, bought cocktails from a cash bar, and awaited results.

Cruz's father, pastor Rafael Cruz, opened the party with an overtly partisan prayer.

"Father," he prayed, "we call on your favor to see a red tsunami come across Texas. ... We thank you Lord God that Texas will remain bright red."

The thin margin fell well short of a red tsunami, and setbacks in U.S. House contests also shifted the state's hue toward purple. Later, with victory official, Pastor Cruz returned to gloat.

"You can't buy Texas! That's the message to Francis O'Rourke," he told the crowd. "The message to George Soros — you cannot buy Texas! The message to Chuck Schumer: You cannot buy Texas. ... Take your money and go back to California. Take your money and go back to New York!"

NBC and ABC projected the narrow victory for Cruz shortly after 9 p.m., with about three-quarters of the votes reported. The Associated Press called the race around 9:30 p.m.

With that, said Michael Berry, a conservative radio host in Houston who introduced the victorious senator, "We said the tea party was still alive."

1 / 5Republican Sen. Ted Cruz addresses supporters Tuesday night at the Hilton Post Oak in Houston after retaining his seat in a tight race against Democratic challenger Beto O'Rourke(Ryan Michalesko / Staff Photographer) 2 / 5A Texas flag lays draped over Ted Cruz's face campaign signs before an election night party for Sen. Ted Cruz, R-Texas, on Tuesday, Nov. 6, 2018, at Hilton Post Oak by the Galleria in Houston.(Ryan Michalesko / Staff Photographer) 3 / 5Cruz supporters enter as the doors open to an election night party for Sen. Ted Cruz, R-Texas, on Tuesday, Nov. 6, 2018, at Hilton Post Oak by the Galleria in Houston. (Ryan Michalesko/The Dallas Morning News)(Ryan Michalesko / Staff Photographer) 4 / 5The stage is set for U.S. Senate candidate Rep. Beto O'Rourke's (D-TX) election party at the Southwest University Park baseball stadium in El Paso, Texas, Tuesday, November 6, 2018. O'Rourke is facing incumbent Sen. Ted Cruz (R-TX) in a close race for the U.S. Senate seat. (Tom Fox/The Dallas Morning News)(Tom Fox / Staff Photographer) 5 / 5People line up outside Southwest University Park baseball stadium in El Paso, Texas to see U.S. Senate candidate Rep. Beto O'Rourke (D-TX) during his election party, Tuesday, November 6, 2018. O'Rourke is facing incumbent Sen. Ted Cruz (R-TX) in a close race for the U.S. Senate seat. (Tom Fox/The Dallas Morning News)(Tom Fox / Staff Photographer)

Texas is evolving

Even in defeat, O’Rourke put to rest the idea that Republicans hold an iron grip on Texas.

“It shows that Texas can be in play with the right candidate. It’s not a foregone conclusion anymore that a candidate can’t run in Texas,” said Marc Stanley, a Dallas lawyer and longtime Democratic financier who led the Fire Ted Cruz super PAC — the group behind the viral "Bernie” ad from Austin director Richard Linklater.

The tongue-in-cheek spot mocked Cruz for standing with Trump even though he'd called Cruz's wife ugly and alleged that his dad was involved in the JFK assassination.

For Cruz, a key turning point came in a different viral moment: When O'Rourke defended, at length and without apology, the protests by NFL football players who kneel during the national anthem to draw attention to police-on-civilian violence.

His national profile skyrocketed and along with it, the pace of his fundraising. In the three months ending Sept. 30, O'Rourke brought in $38 million, pushing his total above $70 million and setting new records.

The upside came at a high price. What liberals heard as an eloquent defense of free speech gave Cruz one of his most potent lines of attack.

Texans, he would declare soon and often, kneel to pray and stand for the flag.

Few O'Rourke backers were watching results as closely as Julian Castro, former Obama housing secretary and San Antonio mayor, who is eyeing a run for president.

"If we vote, then Texas is a competitive state," said Castro. "Things are changing in Texas and in 2020 this state will be at play."

Some fans were already calling on O'Rourke to run for president in 2020, though with a resume of just three terms in the U.S. House and a defeat in his home state, that's unlikely. But his star is rising and he could end up in a Democratic president's Cabinet.

"Beto has already won. He awoke a new generation of people who want and need to believe," said Mario Porras, who worked on O'Rourke's congressional staff for three years, at his election night party.

Beto, please run for President in 2020. pic.twitter.com/RBIRB3KduJ — Michael Skolnik (@MichaelSkolnik) November 7, 2018

President Donald Trump shakes hands with Sen. Ted Cruz (R-Texas), during a campaign rally for Cruz and other Texas Republicans in Houston, Oct. 22, 2018. (Doug Mills/The New York Times)

Trump factor

Nearly two-thirds of Texas voters in an Associated Press exit poll said the president was on their mind when they cast a ballot.

“The type of campaign that O’Rourke ran depended on a polarizing force like Donald Trump in the White House. Had Hillary Clinton been in the White House, Beto O’Rourke’s message wouldn’t have struck the same chord,” said Mark Jones, a Rice University political scientist.

Cruz got a bump from the humming economy Trump has presided over, and in the closing days of the race asked rhetorically: "Who in their right minds would screw that up?"

Richard McCall, 43, an aircraft mechanic, wore a "Don't California My Texas" T-shirt to a Cruz rally

near Humble on Monday night. Trump, he said, "is doing a great job when it comes to the economy," and gets a bum rap for being crass.

“That’s how society is. Everybody’s like that. Nobody has a filter anymore. People don't want the president to be like that," he said. "But you know what? My 401k looks pretty good."

Cruz berated fellow Republicans as squishy. O'Rourke appealed to "people who were tired and upset with hyperpartisan politics," Jones said.

Alas for him, lots of Texans rejected his liberalism and genuinely appreciated Cruz’s pugilism.

Once Cruz awoke to the threat, it didn’t take long for him and allies to strip away the non-ideologue image O’Rourke projected.

“Cruz did not take Beto seriously up until the summer,” Jones said, but “once he did, he ran an effective campaign,” showing centrist Republicans “that beyond the image of a post-partisan, punk-rocking, skateboarding, Whataburger-eating dude, Beto O’Rourke was still a liberal.”

Border correspondent Alfredo Corchado reported from El Paso. Austin Bureau Chief Robert T. Garrett contributed from Austin.