The personal animosity that broke out onstage between Texas Gov. Rick Perry and former Massachusetts governor Mitt Romney during Tuesday night’s Republican presidential debate is rooted in long-standing tensions between the two that may help shape the nominating contest.

Through the mid-2000s, Perry and Romney were rival governors — Perry’s big state afforded him a national profile, while Romney, nursing White House ambitions, cultivated one for himself.

They did not have a productive working relationship, according to Republicans who worked with both men, and each harbored a disdain for the other that was seemingly driven by cultural stereotypes and their perceptions of each other. They share little in their upbringings, careers, faiths or lifestyles.

“There are significant cultural differences between them that only make their contempt for each other more severe,” said Jason Cabel Roe, a Republican strategist who has worked with both men and is now supporting Perry. “Perry comes from a rural, working-class background — up by the bootstraps, work hard to survive and make it. Romney was a guy who was born to pretty good economic circumstances and only made his personal economic circumstances better over the course of his professional career.”

This dynamic manifested itself in a particularly caustic clash at Tuesday’s debate in Las Vegas, with Perry attacking Romney so personally and persistently over his hiring of a lawn-care company that employed illegal immigrants that Romney, for once, lost his cool. He was testy in his responses and appeared agitated. He tried to speak over Perry to finish his points, placed his hand on Perry’s shoulder to quiet him and appealed to the moderator, CNN's Anderson Cooper, to referee the fight.

Romney’s political advisers said the moment projected strength — that the candidate could defend himself and would not be so easily bullied. But to some of his longtime friends, the exchange was a bit worrisome.

“It looked thin-skinned. It looked visibly provoked,” said one friend, who, like others interviewed, spoke on the condition of anonymity to be frank about Romney’s performance. “I don’t think he has a temper as much as he thinks he’s always right.”

“Mitt is a very reserved man, and the fact that he was raising his voice and making his point in a somewhat excessive manner was, in my mind, a little different than the way I’ve always seen him behave,” said another friend who has known Romney for decades. “I just think he was so frustrated, he wanted to prove his point.”

Perry signaled from the moment he walked onstage at the Venetian hotel’s convention center Tuesday night that he was armed for combat with Romney. Introducing himself to the audience, the Texas governor labeled himself “an authentic conservative — not a conservative of convenience,” drawing an immediate contrast with Romney, whose positions on such issues as abortion and same-sex marriage have changed over the years.

The two battled on a range of topics. At one point, it seemed they might be at loggerheads over religion, too, until Romney accepted Perry’s denouncement of a Texas evangelical pastor’s remarks calling Mormonism, Romney’s faith, “a cult.”

The night signaled not only the beginning of a more antagonistic phase of the campaign, but also that, despite volatility in opinion polls, Perry and Romney each consider the other his most formidable opponent.

“Both of them at one time or another have been the front-runner, they’re the ones that most people think will go the distance, and it’s going to get heated,” said David Wilkins, a Perry supporter and former South Carolina House speaker. “They are both competitive individuals, and so it’s not surprising that they would go after each other.”

Donna Sytek, a former New Hampshire House speaker who is backing Romney, said the clash “was inevitable.” But she said that because Perry’s attacks on Romney were over issues thoroughly vetted during Romney’s 2008 campaign, she does not think they will sway many primary voters.

“It’s nothing new,” Sytek said. “All his warts were already exposed.”

Perry signaled Wednesday that he will try to show that he can do more than bicker with Romney, offering up the outline of a plan to rehabilitate the economy that he said would include spending cuts, entitlement reforms and a flat tax.

As he addressed the Western Republican Leadership Conference, Perry managed to get in a few digs at Romney. “You won’t hear a lot of shape-shifting nuance from me,” he vowed. “I’m going to give the American people a big, heaping helping of unbridled truth.”

Meanwhile, Perry’s campaign advisers promised more attacks.

“We have and will continue to work to expose the fact that beneath the slick exterior is someone who changes positions with the wind, who has no philosophical core and who has a record that is not conservative,” Perry communications director Ray Sullivan said.

The Romney team says it is prepared.

“This is not a minuet,” said Tom Rath, a New Hampshire-based senior adviser to Romney. “This is not some elegant form of ballroom dancing. This is a contact sport. . . . At some point, there’s going to be more back-and-forth in this race, and we would be naive if we didn’t expect it to happen.”

Tumulty reported from Las Vegas.