Japanese Prime Minister Shinzo Abe on Friday promised he will keep his nation out of war following the introduction of contentious new security legislation, a day after China announced it is building its second aircraft carrier.

In September parliament in the officially pacifist nation passed security bills opening the door for Japanese troops to engage in combat overseas for the first time since the end of World War II.

The legislation was met with strong public resistance at home with tens of thousands taking part in street protests, while also fuelling anger in China and on the Korean peninsula.

Critics have warned that the changes could see Japanese troops dragged into far-flung foreign conflicts similar to the US invasions of Iraq or Afghanistan.

“Under the new legislation for peace and security, we will prevent war by taking all possible preparations for any circumstances,” Abe said in a New Year’s message.

“We have successfully built a foundation for handing down a peaceful Japan to the generations of our children and grandchildren.”

Abe’s message came a day after China announced it was building its second aircraft carrier, which will have a displacement of 50,000 tonnes and carry China’s indigenous J-15 aircraft along with other planes.

Beijing has rapidly expanded its military in recent years, rattling its neighbours and attracting the attention of the United States, which is making a foreign policy “pivot” towards Asia.

Relations between Japan and China — Asia’s two biggest economies — have often been strained over competing claims of the Senkaku islands, or Diaoyu in Chinese.

Last month, a Chinese coast guard ship which appeared to be armed with several cannon entered what Tokyo regards as its territorial waters near the disputed islands.

Despite steps to improve ties, distrust remains high as China is wary of moves by Abe to raise Japan’s military profile while Tokyo frets about Beijing’s increasing regional and global assertiveness.