Qatar and Bahrain announced late Wednesday that they had agreed to end a long-running diplomatic feud and re-establish relations.
Bahrain in 2017 joined Saudi Arabia, the United Arab Emirates and Egypt in imposing a diplomatic blockade on Qatar. The countries' rivalry goes back even further, however, and Bahrain is the last to renew ties.
Agreement on the reconciliation was reached in talks at the Gulf Cooperation Council headquarters in Saudi Arabia, Qatar's foreign ministry said.
The neighbors "decided to restore diplomatic relations between the two countries according to the principles of the United Nations charter," said a foreign ministry statement.
"The two sides affirmed that this step stems from the mutual desire to develop bilateral relations and enhance Gulf unity and integration," it added.
Bahrain's foreign ministry released a similar statement, the country's state news agency reported.
Saudi Arabia, the UAE, Bahrain and Egypt imposed a blockade in 2017, accusing Qatar of supporting extremist organizations in the region and becoming too close to Iran.
The four countries banned Qatari planes and ships from using their airspace and territorial waters.
A reconciliation accord was sealed in January 2021. The three other states have already renewed relations, though the UAE and Qatar have yet to reopen their embassies.
UAE and Qatari officials held their latest reconciliation meeting last week, with a Qatari foreign ministry spokesperson describing a "positive atmosphere".
Relations between Qatar and Bahrain have been more difficult to restore because of thorny issues including their maritime border. The two sides regularly accuse each other of illegally detaining fishermen from the other country.
The Qatar-Bahrain reconciliation comes amid a flurry of regional efforts to resolve disputes. Arch-rivals Saudi Arabia and Iran agreed last month to resume relations seven years after formally breaking off ties.