Updated at 6:15 p.m. with comments from O'Rourke.

UVALDE — Sen. Ted Cruz, who is in a heated race for re-election against Democrat Beto O'Rourke, said he supports ending birthright citizenship for children born in the country to unauthorized immigrants but it is an "open question" how the government should do that.

"I have long supported ending birthright citizenship," Cruz said following a campaign rally in Uvalde.

President Donald Trump proposed doing away with birthright citizenship through an executive order in an interview with the news website Axios released Tuesday.

"There are some legal scholars who argue that it takes a constitutional amendment, others have argued that it can be done through statutory means," Cruz said. "I suspect whatever method is used will be challenged in court so ultimately, the courts will sort out the proper mechanism. But I think as a policy matter, ending birthright citizenship makes a lot of common sense."

Cruz punted on whether an executive order is the right approach. Cruz was a strong opponent of Obama's use of an executive order to confer protection from deportation to millions of unauthorized immigrants through the DACA program, which many conservatives criticized as "government overreach."

"I would need to examine the legal arguments behind an executive order, and I haven't seen those yet," Cruz said.

O'Rourke said he "absolutely" opposes overturning the birthright citizenship guarantee codified in the 14th Amendment. And he accused Trump of playing on fears for political gain just before the midterms.

"Interesting that he tries to stoke paranoia and fear about a few thousand migrants who are still hundreds of miles, weeks away from the US-Mexico border if they even make it this far," he said Tuesday evening on a special edition of MSNBC's Hardball with Chris Matthews, broadcast from the University of Houston. "I think he's trying to play upon the worst impulses of this country."

Other Democrats also blasted Trump's move.

"If you're born in America, you're an American. Period," said Texas Democratic Party chairman Gilberto Hinojosa. "This is yet another desperate attempt from Donald Trump to divide and incite fear."

Some Republicans, among them House Speaker Paul Ryan, rejected Trump's claim of authority to wipe away a constitutional right, drawing a parallel to objections they lodged when Obama tried to sidestep Congress.

"You obviously cannot do that," Ryan told a Kentucky radio station, according to Politico. "You cannot end birthright citizenship with an executive order. ... As a conservative, I'm a believer in following the plain text of the Constitution, and I think in this case the 14th Amendment is pretty clear, and that would involve a very, very lengthy constitutional process. But where we obviously totally agree with the president is getting at the root issue here, which is unchecked illegal immigration."

In Uvalde, Cruz said "virtually every country on Earth doesn't allow children of those there illegally to become citizens automatically" and doing so encourages people to break the law. He said there is an industry of "birth tourism" where women in their last months of pregnancy come to the United States to have their child here and confer citizenship on them.

"That isn't a policy that makes any sense," he said.

In 2011, while running for the Senate, Cruz said on a questionnaire that he wanted to end birthright citizenship but didn't elaborate.

In August 2015, Trump — at the time the front-runner for the GOP nomination — issued a campaign memo outlining his approach to immigration that included a vow to tighten the border, deport millions, and end the automatic right of citizenship to anyone born on U.S. soil.

Cruz, campaigning days later at the Iowa State Fair, lauded Trump for rekindling a national debate on immigration and, refusing to be outflanked, emphasized that he had likewise supported a ban on birthright citizenship for years.

"In 2011 and today, I said we should end birthright citizenship. Because it doesn't make sense as a policy matter to incentivize and encourage illegal immigration," Cruz said.

Back then, he said he supported Trump's call for a constitutional amendment to overturn the 14th Amendment, which courts have for decades interpreted to confer automatic citizenship for anyone born on American soil.

He also said he supported another approach: a bill from Rep. Steve King of Iowa, an immigration hardliner, that would ban birthright citizenship by overturning federal court rulings on the issue.

He made no assertion at the time that a presidential order would suffice.

"There's a good faith argument on both sides as to whether to take a constitutional amendment or take a statute," he said in Iowa at the time.

He also rejected the idea that the term "anchor babies" was an offensive way to refer to infants born with U.S. citizenship, whose status makes it easier for relatives to obtain entry into the United States.

On Tuesday, he asserted that foreigners game U.S. citizenship rules by engaging in "birth tourism."

"There's a practice known as birth tourism where women who are in their eighth or ninth month of pregnancy come to America on a tourist visa to give birth in the United States and confer citizenship on that child," Cruz said. "That isn't a policy that makes any sense."

Rep. Louie Gohmert, R-Tyler — a favorite of Trump's — has long railed against birthright citizenship. In addition to "anchor babies," Gohmert has warned of "terror babies" born to women from China, who time their visits to the United States to ensure U.S. citizenship for babies. Those young Americans could be trained overseas and return years later, moving freely in U.S. society, Gohmert has claimed.

Rep. Joaquin Castro, D-San Antonio, said flatly on Tuesday that "the President does not have the authority to unilaterally change our Constitution. The 14th Amendment makes clear that those born or naturalized in the United States are citizens. ... It's clear this plan is solely to suit Trump's goals of scapegoating immigrants, dividing our nation, and distracting us from his harmful policies."

According to the Center for Immigration Studies, which advocates for limiting both legal and illegal immigration — and an end to birthright citizenship — the United States and Canada are the only advanced economies as rated by the International Monetary Fund that grant automatic citizenship to any child born on their soil, regardless of whether their parents were in the country with permission or are themselves citizens.

Worldwide, 30 countries grant such citizenship.

Cruz himself was the unwitting recipient of birthright citizenship from Canada, where he was born to a mother who was a natural born American and a father who was still a Cuban citizen at the time. Rafael Cruz later became a naturalized American.

Ted Cruz renounced his Canadian citizenship in June 2014 after The Dallas Morning News revealed that he had been a dual citizen since infancy.

Austin correspondent James Barragan reported from Uvalde. Washington Bureau Chief Todd J. Gillman reported from Dallas.