CLIVE, Iowa — Nikki Haley has long tried to set herself apart from her Republican presidential rivals on foreign policy, peppering her speeches with anecdotes about serving as U.N. ambassador in the Trump administration and the threats she sees from China and Russia.

The war provoked by Hamas’ attack on Israel has shaken American politics — and put the primary race in her wheelhouse.

Haley remains well behind former President Donald Trump in polling. After two energetic debate performances, where Trump didn’t participate, she is trying to position herself as his chief rival by drawing contrasts on how they view U.S. responsibility in foreign affairs.

She’s tying the war between Israel and Hamas to her conservative domestic priorities, arguing that both Israel and the U.S. could be made vulnerable by what she calls “distractions.”

“If you look at how divided America is, if you look at how distracted America is, when that happens, our enemies take notice, because it shows weakness,” she said in an interview this week. “We are seeing in Israel, they have had distractions, and you see this happen. We should not think we’re so immune that we can continue to have this division and distraction, and that we’re not going to pay a price for it.”

Pressed on what she meant, she said she wouldn’t criticize Israel but cited a number of issues in the U.S., including the fall of House Speaker Kevin McCarthy, the rising national debt and spiking numbers of illegal crossings and fentanyl seizures at the U.S.-Mexico border.

Haley and other Republicans argue that extremists could cross the southern border to stage a similar attack in the U.S. While there’s no public evidence that Hamas has infiltrated the U.S. through Mexico, the Department of Homeland Security said in a national threat assessment this year that people with “potential terrorism connections” continue to attempt to enter the country.

The Republican field has lined up behind Israel since Saturday and blamed President Joe Biden for his handling of relations with Iran, notably a deal to return American hostages that included a $6 billion transfer of seized funds to Tehran. Iran has long supported Hamas, though U.S. officials say there’s no conclusive evidence that Iranian agents were involved in the most recent attack.

Since before the war, Haley has gone after rivals on issues like U.S. support for Ukraine against Russia’s invasion and how Washington deals with China.

In June, Haley criticized Trump for being too friendly to China during his time in office, also warning that weak support for Ukraine would “only encourage” China to invade Taiwan, a viewpoint shared by several of her GOP rivals.

In the first GOP debate in August, she attacked Vivek Ramaswamy’s argument that the U.S. shouldn’t support Ukraine in its defense against Russia’s invasion, telling the 38-year-old entrepreneur, “You have no foreign policy experience, and it shows.”

Last month, she critiqued his use of the TikTok video sharing app over concerns about its Chinese ownership, telling him during that debate, “Every time I hear you, I feel a little bit dumber for what you say.”

Ramaswamy in turn has labeled Haley a war profiteer, saying in August that he wished her “well on your future career on the boards of Lockheed and Raytheon.”

Haley has not worked for either defense contractor but did serve on the board of Boeing — the aerospace giant with major government business — after leaving her ambassador post.

Haley and others at the GOP debates have tried to dislodge Trump from the top of the field. Trump has called for future debates to be canceled.

And after Florida Gov. Ron DeSantis characterized the Russia-Ukraine war as a “territorial dispute,” Haley said he was showing “weakness.”

Bill Strong, a retired international banker who has been raising money for Haley, said potential donors were discussing Haley’s international experience as an asset during his fundraising calls Monday.

“This underscores, or reemphasizes, the importance that the president of the United States know what they are doing on the world stage,” Strong said. “They have to know the region. They have to know the players. Nikki knows them all extremely well. No one else does. You can argue the former president doesn’t.”

Former Illinois Gov. Bruce Rauner had been a DeSantis donor but is now contributing to Haley’s campaign for president and encouraging others to follow suit.

“She’s positive in the sense that she’s not out criticizing other people constantly or belittling people who disagree with her,” said Rauner, a wealthy businessman who now lives in Florida. “She’s smart. She’s tough. She’s conservative. She’s a doer. And she’s what I call a happy warrior.”

Haley’s fierce advocacy of Israel was a defining theme for her two years as U.N. ambassador.

In 2018, she defended Israel’s use of force against Palestinian demonstrators in Gaza and walked out of a Security Council session as the Palestinian envoy began to speak.