After a decade of talks, Japan and China agreed on Wednesday to set up a security hotline to defuse maritime incidents that could ignite tension between Asia's two largest military powers.

The deal is the latest result of a push to improve ties strained by lingering acrimony over Japan's wartime occupation of swathes of China and a dispute over the ownership of islets in the East China Sea.

In a public ceremony after a summit meeting in Tokyo, Japanese Prime Minister Shinzo Abe and Chinese Premier Li Keqiang signed a pact to set up within 30 days a hotline for senior defense officials to communicate during incidents involving each others' naval vessels or military aircraft.

Talks on the hotline had stalled in 2012, after the Japanese government bought the disputed islands, known in Tokyo as the Senkaku, and in Beijing as the Diaoyu, from a private landowner.

The step aimed to halt a more inflammatory purchase by the Tokyo city government, then headed by a nationalist governor.

China had also resisted Japan's insistence that the agreement should not cover the territorial waters surrounding the islets, which are controlled by Japan.

"It does not include the Senkakus," a Japanese government official said during an earlier press briefing.

Besides the hotline, Wednesday's pact provides for regular meetings between both nations' defense officials and a mechanism for their naval vessels to communicate at sea to avert maritime incidents.

Known as the Code for Unexpected Encounters at Sea (CUES), the procedure is used by other nations, including the United States.

Besides having Asia’s second-largest military, Japan is defended by U.S. forces that have used it as their main Asia base since the end of World War II. A security treaty obliges Washington to aid Tokyo if its territory is attacked, including the disputed islets, even though the U.S. does not support either side.