The Trump administration warmly welcomed the visiting emir of Qatar on Monday, approving a new arms sale to the Persian Gulf state and describing it as a “valued partner and longtime friend.”

Defense Secretary Jim Mattis, who opened two days of talks with Emir Tamim bin Hamad al-Thani at the Pentagon, praised Qatar’s “critical support” for operations against the Islamic State. “We don’t take this relationship for granted, and we appreciate what you do,” he said before reporters were ushered out of their meeting.

Al-Thani is scheduled to meet and have lunch on Tuesday with President Trump, who last summer accused Qatar of funding terrorism and posing a threat to the region.

At that time, Trump appeared to be taking his cues from Saudi Arabia and the United Arab Emirates, two U.S. allies whose longtime feud with their gulf neighbor erupted just days after the president visited Riyadh, where, he said, he learned from them of bad Qatari behavior.

Mattis and then-Secretary of State Rex Tillerson disagreed, pointing out to Trump that few states in the region have clean hands regarding past terrorism funding. They reminded him that Qatar hosts the forward headquarters of the U.S. Central Command, with about 10,000 service members at a base serving as the hub for U.S. air operations in Syria, Iraq and Afghanistan.

During the summer, Tillerson negotiated and signed a memorandum of understanding with Qatar on counterterrorism cooperation, and the Pentagon sold Qatar 36 F-15 fighters for $12 billion.

By September, Trump had changed direction and called on the Saudis and Emiratis to lift their blockade of Qatar and settle their disagreements. If they could not come to terms, he said at the time, he would bring their leaders to Camp David and negotiate among them.

Saudi Arabia and the UAE have rejected U.S. arbitration, along with Egypt and Bahrain, who had joined them in breaking relations and imposing a blockade of Qatar. Most recently, the White House reactivated the invitation, with plans to hold a Camp David meeting in May, following last month’s visit to Washington by Saudi Crown Prince Mohammed bin Salman, this week’s visit by al-Thani, and an upcoming trip here by Mohammed bin Zayed, the crown prince of Abu Dhabi and de facto UAE leader.

A Camp David summit for the six Persian Gulf Coordinating Council members — Saudi Arabia, the UAE, Qatar, Bahrain, Kuwait and Oman — on a range of issues has been tentatively scheduled for September. If they don’t settle their differences by then, a senior administration official said, the administration plans to put the dispute on the agenda.

The gulf states sit down together — without the United States — at an Arab League summit this month in Riyadh.

From the perspective of their gulf and Egyptian critics, Qatar’s most egregious sin is allowing its state-funded media to give voice to Saudi and other critics of their governments, including hard-line Islamists.

While they have not spoken to each other, the quarreling allies have drawn Congress and the U.S. public into their dispute with multimillion-dollar expenditures on lobbyists and on media campaigns in the United States.

Charges that Qatar hosts representatives of the Taliban and Hamas in Doha, the Qatari capital, and provides extensive funding to Hamas in Gaza, have had some resonance among lawmakers.

Both organizations originally positioned themselves in Doha with the acquiescence of the United States, which has found their presence useful for negotiating purposes.

At the same time, Israel has met with Qatari officials and tacitly approved millions of dollars of Qatari funding for Hamas-governed Gaza.

The United States, Israel and much of Europe have labeled Hamas a terrorist organization. Qatar insists, and its gulf neighbors dispute, that it funds only the political wing of the organization and not its military side, and provides only infrastructure and energy aid.

The Arab world is split over Hamas, an offshoot of the Muslim Brotherhood. Egypt, whose ruler overthrew an elected Brotherhood government, and others consider it a terrorist organization. But in countries such as Jordan and Morocco, it operates as a legitimate political party.

Early in the Trump administration, efforts to designate the Brotherhood as a foreign terrorist organization were stopped, in part by Tillerson, who explained in a June 14 congressional hearing that its status in various countries was part of the “complexities” of U.S. relations in the region.

Even Egyptian relations with Hamas have thawed over the past year, with both seeing reasons to cooperate, despite reservations by Egyptian President Abdel Fatah al-Sissi about its Brotherhood ties. Last summer, Hamas agreed to increase its border security to assist Egypt in fighting an insurgency in the Sinai Peninsula.

In return, Egypt let desperately needed fuel into Gaza, to ease the power crisis for its 2 million residents.

Both John Bolton, Trump’s new national security adviser, and secretary of state nominee Mike Pompeo have in the past called for the Brotherhood to be designated a terrorist organization.

Loveday Morris in Jerusalem contributed to this report.