Newt Gingrich said in Tuesday's presidential debate that he couldn't imagine deporting illegal immigrants who have been in the US a long time. When Rick Perry said something similar, his collapse began.

Republican presidential candidates sparred over national-security issues Tuesday night, differing sharply on a range of issues – from immigration to aid to Pakistan to the pace of withdrawal from Afghanistan.

The debate was the second focusing on foreign policy and national security issues in a little over a week. It was also the first since former House Speaker Newt Gingrich surged to the top of several polls.

So perhaps the biggest talking point of the night was Mr. Gingrich's stance on illegal immigration. Departing from the orthodox Republican line of opposing any form of amnesty, Gingrich said he could not imagine an America that was not “humane” and that did not allow immigrants who have lived and worked in the country “for 25 years” to remain in their families and communities and legalize their status.

Texas Gov. Rick Perry, who heads the state with the longest stretch of the southern border, promised to “shut down” the US-Mexico border within a year of taking office. After that, he said, the issue of what to do about illegal immigrants already in the country could be addressed.

Governor Perry, a one-time darling of the Republican presidential campaign, saw his high-flying numbers plummet, especially among conservative voters, after he made comments on immigration similar to Gingrich’s at a debate earlier this fall.

In theory, the debate should have played to new king-of-the-hill Gingrich's strengths. In a recent poll by Quinnipiac University, 46 percent of likely Republican voters picked Gingrich as the candidate who would do the best job handling foreign policy, compared with 16 percent who picked Romney. In a new CNN poll, 36 percent of Republicans and Republican-leaning voters said Gingrich is the most qualified to take on the duties of commander-in-chief, compared with 20 percent who chose Romney.

Gingrich advisers attending the debate said their candidate hadn’t shied away from taking what he believes is a pro-family stance on immigration, and they said the debate should only enhance the perception among Republican voters that Gingrich has a command of the issues.

“I’m sure what he said [on immigration] will ruffle some feathers, but overall people will see he has a grasp of foreign-policy issues, which is what this debate was about,” said Ilan Berman, a Gingrich foreign-policy adviser.

The moments of sharp disagreement in Tuesday night’s debate – the 11th of the campaign – suggests a lack of Republican unity on how to take on an incumbent Democratic president who achieves some of his best marks with American voters on foreign-policy issues.

When Mr. Romney outlined a plan for Afghanistan that would leave more US troops there for longer than Obama's own plan, Jon Huntsman Jr., a former ambassador to China, shot back, “I totally disagree,” adding he would bring troops home faster and spend the savings on rebuilding America.

“We don’t need 100,000 troops,” Mr. Huntsman said.

“This is not the time for America to cut and run,” Romney retorted.

The candidates said surprisingly little about China, focusing more attention on Iran.

Romney said he would impose “crippling sanctions” on Iran, repeating a formula used in the past by Secretary of State Hillary Rodham Clinton. Herman Cain, the former pizza chief executive, said he would assist Israel in attacking Iran provided the Israelis presented a credible attack plan – something he said would be difficult given Iran’s “mountainous terrain.”

Gingrich said the focus of any viable Iran policy must be not simply addressing the nuclear program but arriving at the real solution, which he defined as “replacing the regime.”

Syria was also cause for disagreement. Perry took the opportunity to tout his proposal for a no-fly zone over Syria – an idea Romney appeared to belittle. Noting that the Syrian regime is not bombing its own citizens but is using its 5,000 tanks against them, he sniffed, “A no-fly zone wouldn’t be the right military action – maybe a no-drive zone.”

Even foreign aid surfaced as a source of disunity. Former Sen. Rick Santorum of Pennsylvania chided his fellow candidates for advocating cuts to foreign aid, saying short-term reductions in international development and health programs including AIDS funding would lead to “a lot more spending on the military” in the long run.