With that upward climb, she has come under more scrutiny. After the second debate last month, the former president attacked her as a “birdbrain” on social media, and Ms. Haley accused his campaign of sending a birdcage and birdseed to her hotel.

Though Mr. DeSantis has drawn attacks from his rivals on the debate stage — including some from Ms. Haley — he has largely avoided initiating heated exchanges, a stance in keeping with his long-running insistence that the primary is a two-candidate contest between him and Mr. Trump. But Ms. Haley’s surge — and her decision to focus her fire on the Florida governor — have clearly forced the DeSantis campaign and its allies to recalculate.

Mr. DeSantis’s super PAC, Never Back Down, reported spending nearly $1 million against Ms. Haley this week, after devoting just $29,000 to anti-Haley messaging during the first half of the year.

The recent exchanges were spurred by dueling television appearances over the weekend on the deepening humanitarian crisis in Gaza. Last week, Mr. DeSantis doubled down on his opposition to helping some of the nearly one million people contending with shortages of food, clean water and shelter in the region. He described the culture in the Gaza Strip as “toxic” and argued that the people of Gaza “teach kids to hate Jews.” Ms. Haley pushed back against this view, saying that large percentages of Palestinians did not support Hamas and that “America has always been sympathetic to the fact that you can separate civilians from terrorists.” (Polling in Gaza supports Ms. Haley’s claim.)

But in an interview on Fox News on Tuesday, Mr. DeSantis cast her words as evidence that she supported allowing refugees from Gaza to come to the United States. The Never Back Down ad from this week spliced the clips from Ms. Haley with comments from Mr. DeSantis criticizing her in an NBC interview. “She’s trying to be politically correct,” he says in the ad. “She’s trying to please the media and people on the left.”

Ms. Haley’s campaign has countered with several emails to supporters and the news media, citing fact checkers who have found that Mr. DeSantis got her statements wrong and rejecting what her campaign officials have described as Mr. DeSantis’s consistent mischaracterizations of her statements and her record.

Spokespeople for both Mr. DeSantis’s campaign and Never Back Down maintain that their critiques of Ms. Haley are accurate.

As governor, Ms. Haley at times voiced the need for the United States to be a welcoming nation for immigrants and refugees. In 2015, she supported the efforts of faith groups to resettle people in South Carolina. But Ms. Haley took an aggressive stance against resettling Syrians in her state after the terror attacks in Paris that same year, citing gaps in intelligence that could make the vetting process difficult.

Now, under fire from Mr. DeSantis, her campaign has underscored her hard-line track record as governor on immigration policies and portrayed her as nothing but staunchly opposed to taking in people from the Middle East. “The truth is, Haley has always opposed settling Middle East refugees in America, believing that Arab countries in the region should absorb them,” read one email to reporters.

The disputes highlight how even as Republicans remain divided on other features of Mr. Trump’s isolationist “America First” agenda, they have unified behind its hard-line approach to immigration and the nation’s borders, with Mr. DeSantis and Ms. Haley largely aligned in their calls to keep out refugees from the conflict zone.

It is widely seen as unlikely that Gazan refugees will be headed for the United States anytime soon. Still, at a DeSantis campaign event in South Carolina on Thursday, the crowd applauded when Mr. DeSantis pledged that as president, he would accept “zero” people from Gaza, adding that he opposed “importing the pathologies of the Middle East to our country.” He also said that any American aid sent to Gaza would end up in the hands of Hamas.

Rick McConnell, a 70-year-old Air Force veteran who heard Mr. DeSantis speak, said he understood that Gazans needed food, water and medical supplies. But Mr. McConnell said that Iran — which he believed was responsible for Hamas’s brutal attacks — should provide that aid.

“Why can’t they help them?” Mr. McConnell said. “We have veterans sleeping on the streets — our veterans.”

The concerns were echoed at Ms. Haley’s events. “If you are living in Gaza, I don’t think you love America or are Christian,” said Corrine Rothchild, 69, a retired elementary school teacher who was still weighing her vote between Ms. Haley and Mr. DeSantis.

Mr. DeSantis, who served on the Foreign Affairs Committee during his time in the House of Representatives, has sought to distinguish himself on foreign policy, pointing to restrictions he signed in Florida that banned land purchases by many Chinese nationals and calling for the use of military force against Mexican drug cartels. In the last week, he also has used state funds to charter flights that have brought home hundreds of Americans stranded in Israel.

Ms. Haley also has sought to make her foreign policy credentials, her hawkish stances on China and her staunch support of Israel central to her campaign. As Mr. Trump’s United Nations ambassador, Ms. Haley forcefully spoke out in support of his formal recognition of Jerusalem as the capital of Israel, as well as his decision to cut American funding to Palestinian refugees.

The two have sparred on foreign policy before. She has criticized Mr. DeSantis for his support of Senator Tommy Tuberville of Alabama and his hold on military nominations over a policy that covers the travel expenses of service members who seek reproductive health care services, including abortions, in other states. She also attacked Mr. DeSantis’s stance on the war in Ukraine, which he called a “territorial dispute” that was not central to U.S. interests — a characterization he later walked back.

In recent days, both have also turned their scorn on Mr. Trump for remarks that he made after the Hamas attack criticizing Prime Minister Benjamin Netanyahu of Israel and referring to Hezbollah, the Iran-backed militant group, as “very smart.” Mr. Trump has since retreated from his comments. He, too, has pledged to reject refugees from Gaza.