The prime minister met Japanese counterpart Fumio Kishida in Downing Street, where the two nations also announced joint exercises and increased working together for disaster relief.
The agreement is the first of its kind between Japan and a European country.
It comes after both PMs condemned Russia's invasion of Ukraine.
The agreement also follows the UK government's defence and foreign policy integrated review, published last year, which announced a "tilt" towards the Indo-Pacific region.
The meeting between Mr Kishida and Mr Johnson also focused on how to exert pressure on Russia and help allies become less dependent on its oil and gas.
Mr Johnson said: "We in the UK recognise that our security in Europe is indivisible from the security, our collective security, in the Asia-Pacific, in the Indo-Pacific region.
"And there is direct read across from the actions of autocratic, coercive powers in Europe, to what may happen in east Asia. And that's why we want to work more closely together."
Japan, a member of the G7 group of leading economies, is part of the Western alliance defending Ukraine and has condemned the invasion, imposed sanctions on Russia and sent non-lethal military aid to Kyiv.
A Downing Street spokesperson said: "Both leaders agreed that Russia's barbaric invasion marked the end of the post-Cold War period and had major implications for wider international stability."
Addressing UK business leaders at London's Guildhall ahead of his meeting with Mr Johnson, Mr Kishida said Japan would utilise nuclear reactors to reduce its dependence on Russian energy.
Mr Johnson said the UK and Japan were "focused on driving growth, creating highly skilled jobs and ensuring we remain technology superpowers".
He also announced that former Business Secretary Greg Clark, the Conservative MP for Tunbridge Wells, as Britain's new trade envoy to Japan.
During the meeting the two leaders ate popcorn from Fukushima, to mark the lifting of restrictions on food products from the Japanese region after the 2011 nuclear disaster.
A flypast took place to mark the visit of Mr Kishida - his first to the UK since becoming prime minister last October - and included two Typhoon fighter jets and the RAF Voyager Vespina.