BEIJING (AP) — China and Vietnam have signed an agreement aimed at resolving bitter maritime disputes that drove relations between the communist neighbors to their lowest level in years, state media reported Wednesday.

The two nations — along with Taiwan, Brunei, Philippines and Malaysia — have competing claims on parts of the South China Sea and potentially rich oil and gas finds. Always fraught relations between the countries worsened this summer, with almost weekly anti-China protests in Hanoi over the South China Sea disputes.

The official Xinhua News Agency said a six-point agreement was signed Tuesday by China’s Vice Foreign Minister Zhang Zhijun and his Vietnamese counterpart Ho Xuan Son. It took place during a visit by Vietnam’s Communist Party chief Nguyen Phu Trong, who held talks with China’s Communist Party boss, President Hu Jintao.

The agreement calls for twice yearly meetings, and for a hotline to be set up to deal with emergencies.

“The two countries should remain committed to friendly consultations in order to properly handle maritime issues and make the South China Sea a sea of peace, friendship and cooperation,” Xinhua quoted the agreement as saying.

It said both sides “should explore interim and temporary solutions” while seeking a long-term resolution.

The agreement is the latest step in efforts by the countries to improve ties. Hanoi clamped down in August on the anti-China protests, while a tentative agreement between China and other southeast Asian nations was reached at a regional security meeting in July in Indonesia.

That comes after Vietnamese fishermen reported being harassed by Chinese vessels, and Vietnam and the Philippines accused China of interfering with their oil and gas exploration activities in areas of the South China Sea claimed all or in part by the three countries and others.

The dispute has dragged in the United States, with the Southeast Asian countries turning to Washington for support. U.S. Secretary of State Hillary Rodham Clinton has said the U.S. has a national interest in seeing disputes peacefully resolved, especially as the South China Sea is home to vital shipping lanes.

Vietnam and China have always had rocky relations and fought a brief border war in 1979.