Mitt Romney and Newt Gingrich sparred here Thursday night over immigration, taxes and wealth, lobbying, and colonizing the moon in a debate that underscored the potential consequences of a loss for either of the leading Republican presidential candidates in Tuesday’s high-stakes Florida primary.

Romney went on the offensive, as he had in a forum on Monday. The former Massachusetts governor said it was “repulsive” for the former House speaker to label him “the most anti-immigrant” candidate in the field. He blasted Gingrich’s moon proposal, saying that if someone had brought it to him, his response would have been “You’re fired.” He goaded his rival into a discussion of his taxes.

Gingrich fought back repeatedly, arguing that he has bigger ideas and a greater willingness to shake up Washington than his rivals do. He protested when Romney hit him, saying, “You’re very quick to draw the widest possible exaggeration.” He said he is a more natural heir to the legacy of Ronald Reagan.

Gingrich held his own but he did not have the kind of dominating performance that marked his appearances in two South Carolina debates. In contrast, Romney, who was less impressive in those forums, stepped up at a critical moment in the Florida campaign.

The tension between the two contenders was evident throughout the evening, confirming how significant the next several days could be in the race. Gingrich arrived here with momentum from his victory in South Carolina, but polls show the contest is extremely tight heading into the weekend.

The friction between Romney and Gingrich overshadowed another strong performance by former senator Rick Santorum (Pa.) and several lively comments from Rep. Ron Paul (Tex.).

The debate, held at the University of North Florida and aired on CNN, was the 19th of the season for the Republicans. It came on a day when Gingrich had launched some of his harshest attacks on Romney, a sign of the pressure he is feeling.

One of the evening’s most fiery exchanges came when moderator Wolf Blitzer asked Gingrich whether he is satisfied that Romney has been transparent enough in releasing his tax returns this week.

Gingrich, who has made it a practice to reprimand debate moderators, called it a “nonsense question.” Blitzer reminded the former speaker that he had said this week of Romney, “He lives in a world of Swiss bank and Cayman Island bank accounts.”

Gingrich responded: “I did. And I’m perfectly happy to say that on an interview on some TV show. But this is a national debate, where you have a chance to get the four of us to talk about a whole range of issues.”

Rather than letting the moment pass, Romney said he was offended that Gingrich wouldn’t stand behind his words.

“Wouldn’t it be nice if people didn’t make accusations somewhere else that they weren’t willing to defend here?” he said. He then rebuked Gingrich for suggesting that there was anything untoward about his finances.

“Mr. Speaker, you’ve indicated that somehow I don’t earn that money,” Romney said. “I have earned the money that I have. I didn’t inherit it. I take risks. I make investments. Those investments lead to jobs being created in America. I’m proud of being successful. . . . What you’ve accomplished in your life shouldn’t be seen as a detriment, it should be seen as an asset to help America.”

It was Romney’s effort to cast in the most positive light possible the issue of his wealth, which Democrats consider a potentially significant liability.

The immigration argument reprised a long-running discussion between the two GOP front-runners. This week, Gingrich pulled a political ad that had applied the “anti-immigrant” label to Romney, but when asked whether he believed that description was accurate, he said he did.

Romney countered: “I’m not anti-immigrant. My father was born in Mexico. My wife’s father was born in Wales. They came to this country. The idea that I’m anti-immigrant is repulsive. It’s simply the kind of over-the-top rhetoric that has characterized American politics for too long.”

Gingrich noted that Romney had attacked him in the past for suggesting that illegal immigrants who have been in the country for a quarter-century or longer should be given the opportunity to become legal residents, though not citizens.

Romney had denounced that idea, suggesting that those who are here illegally should return to their home countries and apply for residency or citizenship, behind those who are on waiting lists. Gingrich said that the notion of “self-deportation” is unrealistic and that rounding up illegal immigrants would be inhumane.

Romney yielded, conceding that he was not advocating doing so. “I’m not going to go find grandmothers and take them out of their homes and deport them,” he said. “Those are your words, not my words.”

Gingrich’s work as a consultant for the housing agency Freddie Mac brought another contentious moment. Romney said Gingrich tried to head off efforts to dismantle Freddie Mac and Fannie Mae.

“I think that was an enormous mistake,” Romney said. “I think, instead, we should have had a whistle-blower and not horn-tooter. He should have stood up and said, ‘Look, these things are a disaster; this is a crisis.’ ”

Gingrich accused Romney of distorting the facts, saying again that his contract called for no lobbying. Then he charged that Romney had profited from the two agencies through his investments in both.

“We discovered, to our shock, Governor Romney owns shares of both Fannie Mae and Freddie Mac,” he said. “Governor Romney made $1 million off of selling some of that.”

Romney said that for the past decade, all of his investments had been made through a blind trust. He said his rival had investments in mutual funds that invested in the agencies. That brought a retort from Gingrich, who said that comparing his investments with Romney’s “is like comparing a tiny mouse with a giant elephant.”

Santorum jumped in to reproach the two, urging them to stop bickering and engaging in “petty personal politics.”

“Can we set aside that Newt was a member of Congress and used the skills that he developed as a member of Congress to go out and advise companies — and that’s not the worst thing in the world — and that Mitt Romney is a wealthy guy because he worked hard?” Santorum asked. “And you guys should leave that alone and focus on the issues.”

Santorum was aggressive again in pressing Romney to defend his Massachusetts health-care plan. When Romney defended the law — which, like President Obama’s health-care law, includes a mandate that people buy insurance — Santorum shot back, “What Governor Romney just said is that government-run top-down medicine is working pretty well in Massachusetts and he supports it.”

The more Santorum pressed his argument, the more unhappy Romney appeared, saying at one point, “It’s not worth getting angry about.”

Gingrich was asked to defend his proposal to establish a moon colony and send a spacecraft to Mars — while still balancing the federal budget.

His rivals weren’t buying. “I don’t think we should go to the moon,” Paul said. “I think we should send some politicians up there.”

Romney was even tougher. “I spent 25 years in business. If I had a business executive come to me and say they wanted to spend a few hundred billion dollars to put a colony on the moon, I’d say, ‘You’re fired.’ ”

Romney stumbled at one moment when he was asked about one of his ads, which criticizes Gingrich for calling Spanish “the language of the ghetto.” Romney said he hadn’t seen the spot and doubted that it had come from his campaign. When later confronted by Blitzer, who said CNN had checked, the candidate acknowledged that he was wrong.

Staff writer Rosalind S. Helderman contributed to this report.