A handout photo released by the Iranian supreme leader’s office shows Ayatollah Ali Khamenei, right, meeting with Prime Minister Mohammed Shia al-Sudani of Iraq, center, and President Ebrahim Raisi of Iran in Tehran on Monday.Credit…Office of the Iranian Supreme Leader, via Shutterstock

Iran’s supreme leader, Ayatollah Ali Khamenei, met on Monday in Tehran with Prime Minister Mohammed Shia al-Sudani of Iraq, telling him that their countries must coordinate to increase pressure on the United States and Israel to end the Israeli military offensive in Gaza, according to official Iranian media.

Mr. al-Sudani traveled to Iran a day after meeting with the U.S. secretary of state, Antony J. Blinken, in Baghdad, where the two discussed the escalating attacks on U.S. military bases in Iraq and Syria by militias aligned with Iran, which have been accompanied by threats of widening the war between Israel and Hamas.

The Biden administration is seeking to contain the war, and Mr. Blinken asked Mr. al-Sudani to hold responsible those found to have carried out attacks against U.S. personnel, making it clear that the United States would retaliate if Iran did not rein in its proxy forces.

Mr. Khamenei’s public remarks appeared to dismiss Washington’s warnings.

“The Islamic Republic and Iraq must coordinate with one another to have more impact,” said Mr. Khamenei in the meeting with Mr. al-Sudani, according to the Iranian media reports.

The Pentagon said on Monday that there had been 38 attacks on U.S. forces in Syria and Iraq since Oct. 17 and that at least 46 U.S. service members had been injured, 25 of whom had suffered traumatic brain injuries. On Oct. 27, the United States carried out airstrikes on two sites in Syria that it said were linked to Iran’s Revolutionary Guards Corps in retaliation for the attacks on U.S. forces.

Mr. Khamenei has repeatedly pledged to destroy Israel and repel U.S. military forces from the region, and the leaders of militant groups in Yemen, Lebanon, Syria, Iraq and Gaza view Mr. Khamenei as a powerful ally, often seeking his advice and consulting with him on strategic issues.

Hamas’s political leader, Ismail Haniya, was in Tehran on Sunday with a delegation of Hamas officials and also met with Mr. Khamenei, according to Iranian media. The two discussed Israel’s war with Hamas, the killing of Palestinian civilians and tensions in the West Bank, according to a brief official readout of the meeting in Iranian media.

Mr. Khamenei told Mr. Haniya that Iran would continue to “fully support Palestinian resistance groups,” in line with its long-held policy, and called on Islamic countries to support the people of Gaza. It was not clear from the Iranian news reports whether Mr. Haniya had requested more military or funding assistance from Mr. Khamenei or whether the two had discussed if and when Iran and Hezbollah in Lebanon, the strongest of the proxy militia, should enter the war to aid Hamas.

Iranian officials have publicly confirmed exchanging messages with Washington and said they do not seek a wider war, nor a direct confrontation with the United States. But they have also warned that if Israel’s military operations continue to kill Palestinian civilians, the region could, as Iran’s foreign minister, Hossein Amir Abdollahian, put it, “spiral out of control.”

Mr. Abdollahian said in an interview last week with The New York Times that the Israel-Hamas war had created a sense of unity among Iran and Arab Muslim countries, including Iranian allies like Iraq and Qatar, as well as rivals like Saudi Arabia and United Arab Emirates.

“The scope and intensity of Israeli regime’s crimes has resulted in unity, cohesion and cooperation among regional countries and Muslim countries,” Mr. Amir Abdollahian said. “We all feel security is an intertwined issue, if there is instability on one part of the region it will spread to other parts as well.”

Eric Schmitt contributed reporting from Washington, D.C.