The United States’ top diplomat sealed a deal Tuesday to intensify Qatar’s counterterrorism efforts, tackling a central issue in the spat pitting the besieged Gulf nation against four other American allies lined up against it.

U.S. Secretary of State Rex Tillerson outlined the agreement at the end of his first visit to Qatar since its neighbors moved to isolate it over grievances including what they allege is its support for extremist groups.

It was his second stop on a shuttle-diplomacy circuit that will take him next to Saudi Arabia, which has shut Qatar’s only land border and is the most powerful of the countries opposing it.

The centerpiece of the visit was the signing of a memorandum of understanding that lays out steps Qatar can take to bolster its fight against terrorism and address shortfalls in policing terrorism funding.

Mr. Tillerson said the deal, the details of which were not made public, has been in the works for a while and included some steps that have already been taken.

“Together, the United States and Qatar will do more to track down funding sources, will do more to collaborate and share information, and will do more to keep the region and our homeland safe,” he said following talks with 37-year-old Emir Tamim bin Hamad Al Thani.

Mr. Tillerson also gave besieged Qatar, which described the deal as the first of its kind in the Gulf, some political backing ahead of his talks in Saudi Arabia on Wednesday.

“I think Qatar has been quite clear in its positions and I think very reasonable,” he said earlier in the day.

Mr. Tillerson, a former oilman with years of experience in the oil-rich region, began his Gulf visit Monday by meeting Kuwait’s ruler, Sheikh Sabah Al Ahmed Al Sabah.

The Kuwaiti leader has been acting as a mediator between Qatar and the quartet of Saudi Arabia, Bahrain, the United Arab Emirates and Egypt.

The four nations broke off relations with Qatar and cut air, sea and land routes with it more than a month ago. They later issued a 13-point list of demands to restore relations and gave Doha 10 days to comply.

The demands include Qatar shutting down news outlets including al-Jazeera, cutting ties with Islamist groups such as the Muslim Brotherhood, limiting ties with Iran and expelling Turkish troops stationed in the country.

Qatar strenuously denies supporting extremist groups and has rejected the demands, saying that agreeing to them wholesale would undermine its sovereignty.

It does, however, at least indirectly support Islamist groups that other nations view as terrorist organizations, such as the Palestinian militant group Hamas. Qatar has hosted senior Hamas officials and is the largest financial patron to the Hamas-ruled Gaza Strip.

Underscoring that uneasy position, Qatari envoy Mohammed al-Amadi signed a new agreement Tuesday with a Palestinian contractor to build eight residential buildings in Gaza. He said his country would continue to support development projects in the seaside territory aid Qatar argues is for the Palestinian people rather than Hamas.

Mr. Tillerson’s arrival in the Gulf coincided with the release by CNN of alleged agreements between Qatar and its neighbors dating from 2013 and 2014 the network says were leaked by a source in the region.

They include a handwritten 2013 deal between the leaders of Saudi Arabia, Kuwait and Qatar to not interfere in the internal affairs of fellow members of the six-nation Gulf Cooperation Council, which also includes Bahrain, Oman and the UAE.

That agreement specifically ruled out support for the Muslim Brotherhood and other unnamed groups that could threaten the bloc’s members.

Qatar sees the Brotherhood as a legitimate political force and has for years hosted its spiritual guide, Sheikh Youssef al-Qaradawi. Saudi Arabia, the UAE and Egypt label the Brotherhood a terrorist organization.

None of the countries involved questioned the authenticity of the documents.

The four anti-Qatar countries said the leaked files “confirm beyond any doubt Qatar’s failure to meet its commitments and its full violation of its pledges.” Their 13-point list of demands in June was tied to those earlier deals and was “fully in line with the spirit of what was agreed upon,” they said.

The head of Qatar’s government communication office, Sheikh Saif bin Ahmed Al Thani, disputed that.

“Their actions demonstrate that the blockading nations are not interested in engaging in honest negotiations to resolve our differences,” he said.

Still, he added, Qatar remains open to talks to solve the dispute.

U.S. officials have said Mr. Tillerson does not expect an immediate breakthrough in the dispute and cautioned that a resolution could take months.

The squabble puts Washington in an uncomfortable position militarily.

Qatar hosts al-Udeid Air Base, the largest U.S. military installation in the Middle East and hub for U.S.-led operations against the Islamic State group in Iraq and Syria. Bahrain is home to the U.S. Navy’s Fifth Fleet, while American surveillance planes and other aircraft fly from the UAE.

Qatar is not new territory for Mr. Tillerson. Before being tapped to be President Donald Trump’s top diplomat, he served for years as CEO of Exxon Mobil.

The Irving, Texas-based oil giant is one of the most dominant players in OPEC member Qatar’s energy industry, and played a major role in turning it into the world’s largest producer of liquefied natural gas.