Nato member Turkey has agreed to support Sweden and Finland's membership of the alliance.
It had initially opposed the Nordic countries' bids to join.
Turkey was angered by what it saw as their willingness to host Kurdish militants. Sweden and Finland could not join Nato without Turkey's support.
Russia strongly opposes the two states joining and has used the expansion of the West's defensive military alliance as a pretext for its war in Ukraine.
But Moscow's invasion has had the opposite effect, with the path now clear for the two countries to join Nato.
Foreign ministers from the three countries signed a joint security pact that addressed Turkey's concerns.
Nato chief Jens Stoltenberg said Sweden agreed to step up its work on Turkish extradition requests of suspected militants.
The two Nordic nations will also lift their restrictions on selling weapons to Turkey, he said.
Finland's President Niinisto said the three countries signed the joint memorandum "to extend their full support against threats to each other's security".
Sweden's Prime Minister Magdalena Andersson said it was "a very important step for Nato".
Turkey President Recep Tayyip Erdogan's office said it "got what it wanted" from Sweden and Finland.
The two Nordic nations announced their intentions to join Nato in May, in response to Russia's invasion of Ukraine.
Mr Stoltenberg had suggested the process could move "very quickly" as they already shared a close relationship with the alliance.
But that was not the case as Nato member Turkey accused the two countries of protecting Kurdish militants and said they would not back their membership. Any Nato enlargement must be approved by all 30 members.
Turkey has long accused Sweden of harbouring what it calls militants from the banned Kurdistan Workers Party (PKK), but Stockholm denies it.
Now the two countries have agreed to some of Turkey's demands, and militants will face a crackdown under amendments to Swedish and Finnish law.
If Sweden and Finland do become members, it will end over 200 years of Swedish non-alignment. Finland adopted neutrality following a bitter defeat by the Soviet Union during World War Two.
Finnish public support for joining Nato was for years at around 20-25%. But since Russia's invasion of Ukraine, it has shot up to a record high of 79%, according to the latest opinion poll. In Sweden, 60% of the population say it was right to apply, again far higher than before the war.
FIFA World Cup Qatar 2022: Smoke-free stadiums and bans on tobacco marketing
Qatar Says it Will Adopt Climate Tech Application in FIFA World Cup 2022
World's deepest shipwreck discovered
Ministry urges public to participate in #WateringBirds initiative