A long-simmering dispute between two top White House aides has boiled into a public battle over the direction of President Donald Trump's foreign policy, with a cadre of conservative groups pushing for the ouster of national security adviser H.R. McMaster.

In recent days, conservative groups and a website tied to Trump adviser Steve Bannon have targeted McMaster as insufficiently supportive of Israel and insufficiently tough toward Iran. They've expressed outrage about the firings of several aides regarded as sympathetic to their views. An online campaign — under the hashtag #FireMcMaster — prompted Trump to declare his support for his adviser.

The dispute reflects the tensions at the heart of Mr. Trump's foreign policy coalition. McMaster is one of several powerful generals in Mr. Trump's orbit who hail from the Republican foreign policy establishment. But Mr. Trump is equally sympathetic to the views of firebrands like Bannon, who are trying to push the party in a new, isolationist direction embodied by his "America First" doctrine.

Get Breaking News Delivered to Your Inbox

McMaster and Bannon have clashed loudly and repeatedly during recent White House discussions over Afghanistan war strategy, according to four administration officials and outside advisers. The officials spoke on the condition of anonymity because they weren't authorized to discuss private conversations.

Afghanistan, however, represents only the latest dispute between McMaster and Bannon, who've also fought over White House personnel.

McMaster, an Army general, recently purged three National Security Council officials who were viewed as close to Bannon or to Michael Flynn, Mr. Trump's previous national security adviser. For people close to Bannon, the moves were seen as telling. The former chief of Breitbart News, who wants Mr. Trump to upend the Washington foreign policy establishment, has bitterly argued against further U.S. entanglement in global conflicts and believes McMaster is adhering to holdover Obama administration policies.

Breitbart, which holds significant influence in Mr. Trump's White House, has promoted a series of anti-McMaster headlines on its website. The Zionist Organization of America on Monday announced it has undertaken a review of McMaster's views on Israel. Dozens of conservative and alt-right social media stars have hammered the national security adviser on Twitter.

The outcry grew so loud that Mr. Trump responded Friday: "General McMaster and I are working very well together. He is a good man and very pro-Israel. I am grateful for the work he continues to do serving our country."

Months earlier, Mr. Trump also defended his adviser, taking a printout of a story suggesting he might fire McMaster and scrawling on it with a Sharpie pen, "This is bull----. You're doing a great job," along with his signature. He had it delivered to McMaster, according to someone who speaks regularly with officials in the Trump administration.

But privately, Mr. Trump has at times expressed some dissatisfaction with McMaster and rued losing Flynn, according to people who have spoken with the president. The White House has said Flynn was dismissed because he did not tell White House officials, including Vice President Mike Pence, about the full extent of his contacts with Russian officials.

Mr. Trump often vents about aides without making changes. And McMaster's position was strengthened by the recent appointment of ret. Gen. John Kelly as Trump's chief of staff.

Bannon's allies say the recent dismissals are evidence that McMaster is ridding the National Security Council of Trump supporters while deferring to career officials left over from former President Barack Obama's tenure. They also chafe at McMaster's involvement in removing Bannon from a prominent role on the NSC earlier this year.

Among those fired: White House intelligence adviser Ezra Cohen-Watnick, a Flynn protégé who previously clashed with CIA leaders.

The Iran nuclear deal also has been a source of disagreement. That Obama-era pact is opposed by Israel and prominent GOP donor Sheldon Adelson, who backs the Zionist Organization of America group that attacked McMaster. Mr. Trump has repeatedly denounced the accord, even as he has granted Iran continued relief from U.S. sanctions under the arrangement. McMaster was among the Trump aides advocating for that course.