In a debate that focused on character and credibility as much as other issues, Perry insisted he had backed off "not one inch, Sir" from what he had written in a campaign-season book published a few months ago.
Romney vouched for his own steadfastness moments later. "There are a lot of reasons not to elect me," he said. "There are a lot of reasons not to elect other people on this stage. ... But one reason to elect me is I know what I stand for. I've written it down. Words have meaning."
The two men assailed one another in the third debate in as many weeks in a race for the Republican presidential nomination growing testier by the day.
Perry runs ahead in national opinion polls, with Romney a close second, and they compete daily for endorsements from members of Congress and other party luminaries in hopes of gaining a permanent edge before the caucuses and primaries begin early next year.
The other contenders on the stage struggled at times to gain the debate spotlight, even as they struggle to gain traction in the polls.
The GOP presidential hopefuls all agreed quickly on one point - that President Barack Obama's handling of the economy was woeful. They said they would cut taxes, eliminate government regulations and take other steps to help create jobs in a nation with 9.1 percent unemployment.
Yet the two-hour event was marked by clashes over Social Security, health care, immigration, gun rights and more.
Romney accused Perry of having said the federal government "shouldn't be in the pension business, that it's unconstitutional," a reference to Social Security benefits.
Noting his rival's denials, Romney mocked him. "You better find that Rick Perry and get him to stop saying that," he said.
Perry soon returned the favor, saying that Romney switched his position on health care between editions of a book he had published. In one edition, Perry said, Romney advocated expanding to the rest of the country the health care program he signed in Massachusetts. "Then in your paperback you took that line out, so speaking of not getting it straight in your book, Sir."
"It's like badminton," said Perry.
The Massachusetts legislation required residents of the state to purchase health coverage or pay a fine, a cornerstone of the law that Obama won from Congress last year that has inflamed conservative voters across the country.
Perry also accused Romney of flip-flopping his views on the rights of gun owners.
In fact, both Perry and Romney have sought to blur if not rewrite portions of their own records as they vie for the nomination.
In Romney's case, that has meant trying to win support from conservative voters despite the moderate positions he held on social issues while he was governor of Massachusetts.
And for Perry, it has meant trying to fend off criticism that his views on Social Security and other issues render him unelectable.
Perry gave no ground on one issue - his support for a state law in Texas that gives the children of illegal immigrants reduced tuition to state colleges and universities.
"If you say that we should not educate children who have come into the state for no other reason than they've been brought there, by no fault of their own, I don't think you have a heart," he said. That drew a retort from former Pennsylvania Sen. Rick Santorum. "No one is suggesting that students who are illegal in this country shouldn't go to colleges and universities," he said, adding that he objects to giving them state subsidies to do so.
"Most folks have to pay the full boat. ... Why should they be given preferential treatment as an illegal in this country?" he said.
There was relatively little jockeying on the economy.
"The president's party wants to take from some people and give to others. That isn't the way to lift America," said Romney.
Perry said his state ranked first in the country five years in the row in attracting businesses looking to relocate. "Something special happened there ... and we plan to keep it that way," he said.
Rep. Michele Bachmann of Minnesota told one questioner, "You should get to keep every dollar you earn," then backpedaled. "Obviously we have to give money back to the government so we can run the government," she said.
The two-hour event was sponsored by Fox News and Google, in keeping with an emerging trend in which mainstream media organizations partner with Internet companies.
Without saying so, former House Speaker Newt Gingrich gave an endorsement of sorts to one of the elements of Obama's job proposals. Asked whether he would renew unemployment benefits for those out of work, he said they should be required to participate in a "business led" job training program. "I believe it is fundamentally wrong to give people money for 99 weeks for doing nothing."
Obama has called for Congress to extend the current system of unemployment benefits, but he also wants to permit states to experiment with the type of training program that has been used in Gingrich's home state of Georgia.
Also on stage were Rep. Ron Paul of Texas, former New Mexico Gov. Gary Johnson, businessman Herman Cain and former Utah Gov. Jon Huntsman.