Microsoft on Tuesday announced a $2.9 billion investment over the next two years in Japan to bolster the country's push into artificial intelligence and strengthen its cyber defences in the face of threats from China and Russia.

The announcement coincides with Japanese Prime Minister Fumio Kishida's visit to Washington, underscoring Tokyo's commitment to becoming a major AI power.

Japan is also expanding its semiconductor industry with the help of big foreign investment. Taiwanese chip behemoth TSMC opened a new $8.6-billion chip factory in southern Japan in February, and is planning a second facility.

Microsoft has become a major player in the advancement of AI through its partnership with ChatGPT-maker OpenAI -- propelling it past Apple as the world's biggest company by market capitalisation.

"This is Microsoft's single largest investment in its 46-year history in Japan," said Brad Smith, Vice Chair and President of Microsoft, who met Kishida on Tuesday.

"These investments are essential ingredients for Japan to build a robust AI economy."

The investment includes providing "more advanced computing resources", according to Smith, including powerful graphics processing units crucial for running AI applications.

Microsoft also pledged to invest in training three million Japanese workers in AI skills over the next three years, and announced the opening of its first Microsoft Research Asia lab in Tokyo that will work on AI and robotics.

The US company also unveiled plans to collaborate with Japan's government to strengthen the country's cybersecurity following an increase in hacking and breaches.

"The threat landscape for cybersecurity has become more challenging," Smith told the Nikkei news outlet.

"We're seeing that from China and from Russia in particular, but we're also seeing growing ransomware activity around the world."

Google in March also launched a new cybersecurity hub in Japan, aimed at helping to upgrade defences in the Asia-Pacific.

Kishida will meet President Joe Biden on Wednesday with defence ties high on the agenda, but also cooperation in technology from space to semiconductors.

Motivated by geopolitical concerns surrounding Taiwan, Tokyo is seeking to bring back the 1980s glory days when Japanese firms such as Toshiba and NEC dominated the microchip market.

As well as the TSMC plants, Japan is ploughing around $6 billion into its next-generation semiconductor venture called Rapidus, involving a host of Japanese firms including Sony and Toyota.

Rapidus is collaborating with US giant IBM with the aim of mass-producing two-nanometre logic chips in Japan from 2027.

On Tuesday, alongside Microsoft's investment, two new AI research partnerships were announced between four US and Japanese universities.

The research programmes, funded by tech firms including Nvidia, Amazon, Arm and SoftBank Group as well as Microsoft, "can help set the standard in this fast-evolving field", US Ambassador Rahm Emanuel said.

Rene Haas, CEO of British chip designer Arm, also hailed the "historic" new university partnerships.

"The unprecedented progress we've seen in AI will transform virtually every industry and improve countless lives," he said.