Indonesia will buy as many as eight Mogami-class stealth frigates from Japan.

The agreement in Tokyo during "two plus two" security talks between Japan's Foreign Affairs Minister Toshimitsu Motegi, Defense Minister Nobuo Kishi, Indonesian Foreign Minister Retno Marsudi and Defense Minister Prabowo Subianto will see Japan sell defense equipment to Indonesia as both countries boost military cooperation to counter China's expansion in the South China Sea and East China Sea.

The two countries will participate in international military exercises and jointly fortify remote islands in the South China Sea.

The ministers "shared grave concern over the continuation and escalation of an attempt to change the status quo by force" and agreed on the importance of observing a rules-based maritime order and respect for international maritime laws, Japan's Foreign Ministry said in a statement.

"Together we will maintain and strengthen a free and open maritime order," said Kishi.

Motegi said it had become difficult "to take for granted the premises that have supported the peace and prosperity of the international community."

Prime Minister Yoshihide Suga said the pact would be the "foundation of further security cooperation between the two countries."

Japan plans to build 22 of the frigates, four of which will be bought by Indonesia. The agreement gives Indonesia the right to build four more Mogami-class frigates at Indonesian dockyards. They will be the most modern operated by the Indonesian Navy.

As well as missile systems the Mogami-class frigates will be equipped with antimine and antisubmarine sonars and operating Sikorsky Seahawk helicopters.