The UK prime minister first met with his Swedish counterpart Magdalena Andersson, before arriving in Helsinki for talks with President Sauli Niinistö.
British Prime Minister Boris Johnson has promised to defend Finland and Sweden if either country comes under attack.
He made the pledge during a whistle-stop tour to the two Nordic nations on Wednesday, where he met first Swedish Prime Minister Magdalena Andersson at her official countryside residence; then Finnish President Sauli Niinistö in Helsinki.
Sweden and Finland are currently considering whether to join NATO following Russia's invasion of Ukraine on 24 February.
This is a key week for the NATO debate, with Niinistö and Finnish Prime Minister Sanna Marin due to announce their decisions on applying to join the military alliance on Thursday morning.
The new agreement will “fortify northern Europe’s defenses, in the face of renewed threats,” Johnson said in a statement.
“These are not a short-term stop-gap, but a long-term commitment to bolster military ties and global stability, and fortify Europe’s defenses for generations to come,” Johnson said in the statement.
Finland shares a 1,340-kilometre land border with Russia, while Sweden doesn't have a land border but has strategically important islands in the Baltic Sea close to the Russian exclave of Kaliningrad.
In practice, Johnson says the deal will also deepen ties between the British military and the Swedish and Finnish armies -- which have already been cooperating increasingly closely under the auspices of the Joint Expeditionary Force, which is made up of ten northern European countries and led by the UK.
The Kremlin has warned of “military and political repercussions” if Sweden and Finland decide to join NATO.
Should Sweden and Finland apply, there will be an interim period between the application and all 30 NATO members’ parliaments ratifying their membership. That process could last anywhere between four months and a year.
"The Russian invasion of Ukraine has changed the equation of European security. It has re-written our reality and re-shaped our future," Johnson said at a Helsinki press conference.
Answering a question about how Russia should feel about Finland's possible NATO membership, President Niinistö said "you caused this. Look in the mirror."
In a statement, the Finnish president's office noted that the pledge of mutual military assistance was "a political declaration and not a legally binding commitment under international law".