Republican presidential candidate Sen. Ted Cruz (R-Tex.) offered his condolences to the victims in Brussels and said, "This is a war." (Reuters)

Sen. Ted Cruz has spent his time in government vowing to preserve civil liberties, often citing the Fourth Amendment to voters on the campaign trail and vowing to shrink government.

But Cruz (R-Tex.) has alarmed some libertarians this week with his proposal to have law enforcement “patrol and secure” Muslim neighborhoods in the United States, which they see as the type of invasive federal program that encroaches on personal freedom.

“I think this is a reflection of his misunderstanding of civil liberties, that you can start surveilling people just because they belong to a group,” said Ron Paul, the former Texas congressman and scion of the modern libertarian movement. “That’s something that’s done in a police state, and it’s not supposed to be done in this country.”

Cruz called for the policing of Muslim neighborhoods hours after Tuesday’s terrorist attacks in Brussels, which killed at least 31 people and injured 270. Cruz said he wants to effectively revive a defunct and controversial counterterrorism program in New York that targeted Muslims.

Cruz’s proposal was embraced by Republican front-runner Donald Trump but met with swift criticism from many others. President Obama, who left Cuba Tuesday, said Wednesday that neighborhood surveillance is done in that country, which Cruz’s father fled in the 1950s.

“The notion that we would start down that slippery slope makes absolutely no sense. It’s contrary to who we are and it’s not going to help us defeat ISIL,” Obama said at a news conference in Argentina, using an acronym for the Islamic State.

Democratic front-runner Hillary Clinton tweeted Wednesday: “When Republican candidates like Ted Cruz call for treating American Muslims like criminals, it’s not just wrong — it’s counter-productive.”

Cruz has spent much of his presidential campaign trying to court libertarians, talking up his desire to shrink government and strengthen personal freedom. Cruz also spearheaded a compromise bill as the USA Patriot Act expired that ended the National Security Agency’s bulk data collection program.

“If you’re a terrorist, we need to track down everything you do, and we need to go out and find you and kill you,” Cruz said in Alabama in August. “But if you’re a law-abiding citizen, the federal government has no business seizing your phone calls or your emails.”

Cruz’s campaign said that the senator is committed to protecting civil liberties and that his proposal is typical police protocol.

Sen. Ted Cruz (R-Tex.), who is seeking the Republican presidential nomination, claps upon arriving for a rally Wednesday in New York. (Pearl Gabel/Reuters)

“It is standard, good policing to direct the resources to where the threats are coming from,” Cruz said Tuesday.

But critics said it smacks of the bloated bureaucratic programs that Cruz said he wants to do away with.

“Personally, I was troubled by it. It certainly sounds more intrusive — more big government, less effective than policies I’d like to see,” said Cato Institute Executive Vice President David Boaz, who is not publicly supporting any candidate.

Cruz has been attempting to thread the needle between the hawkish and more dovish factions of the Republican Party on foreign affairs. He has taken some of his toughest stances on terrorism — repeatedly saying that the United States must “carpet bomb” the Islamic State into oblivion — while warning against unnecessary intervention abroad. Last month, Cruz also went against libertarian sentiment by saying that Apple should help the FBI recover encrypted data from the cellphone of one of the terrorists in San Bernardino, Calif.

Lanhee Chen, Mitt Romney’s chief policy adviser in 2012, sees Cruz’s proposal as part of his attempt to simultaneously win over traditional Republican hawks and libertarian-leaning voters.

“I think he’s doing what makes sense, and that’s where the vacuum is,” said Chen, who also advised Florida Sen. Marco Rubio’s campaign. “I think that many Republican voters want to see a Reagan-esque foreign policy.”

Aside from the ideological debate over Cruz’s comments, some experts say Cruz’s plan is a legal nonstarter.

“Policies that result in warrantless surveillance or monitoring of belief communities are unconstitutional,” said Hina Shamsi, director of the American Civil Liberties Union’s National Security Project.

John Inazu, a professor at the Washington University School of Law, said Cruz’s proposal sounds like “fear mongering,” but there could be ways to increase patrols that would withstand a constitutional challenge.

“The police would still be subject to constitutional constraints before they questioned or detained specific individuals,” Inazu wrote in an email. “At some point, an overly localized presence could raise First Amendment concerns about chilling expression or association.“

Regardless of legality, others also question its effectiveness.

“I think his so-called cure is more costly and less effective than he would allow,” said Richard Epstein, a professor at New York University School of Law. “It turns out once you do the patrols, people on the other side will adapt their behavior in order to minimize their exposure, so it’s not clear that it’s going to work.”