It will allow them to join the nuclear-armed alliance once allied parliaments ratify the decision, the most significant expansion of Nato since the mid-1990s.
The move increases Russia’s isolation since its invasion of neighbouring Ukraine in February and the subsequent conflict.
The protocol means Helsinki and Stockholm can participate in Nato meetings and have greater access to intelligence but they will not be protected by the Nato defence clause that an attack on one ally is an attack against all, until ratification that is likely to take up to a year.
The 30 ambassadors and permanent representatives formally approved the decisions of last week’s Nato summit, when the alliance made the historic decision to invite the two countries to join the military pact.
"This is truly a historic moment," Nato Secretary General Jens Stoltenberg said alongside the foreign ministers of the two countries. "With 32 nations around the table, we will be even stronger."
Nato's 30 ambassadors and Mr Stoltenberg stood together for a photo in which the foreign ministers of Sweden and Finland held up their signed protocols, before breaking out into applause.
Swedish Foreign Minister Ann Linde said on Twitter: "Thank you for your support! Now the process of ratification by each of the allies begins. Look forward to working together in ensuring our collective security."
Despite the agreement in the alliance, parliamentary approval in member state Turkey could still pose problems for their final inclusion as members.
Turkish President Tayyip Erdogan issued a warning at last week's summit in Madrid that Finland and Sweden must first keep the promises made to Turkey in a deal or ratification will not be sent to the Turkish Parliament.
Historic Nato summit - in pictures
After weeks of diplomacy, Mr Erdogan and his Finnish and Swedish counterparts agreed on a series of security measures to allow the two Nordic countries to overcome the Turkish veto that Ankara had imposed in May due to its concerns about terrorism.
But he insisted Ankara could still block the process if the two countries fail to fully meet Turkey’s demand to extradite suspected terrorists with links to outlawed Kurdish groups or the network of an exiled cleric accused of a failed 2016 coup in Turkey.
According to the signed memorandum, Finland and Sweden pledged not to support the Kurdish militant PKK and YPG groups or the network of US-based cleric Fethullah Gulen, which Ankara says staged a 2016 coup attempt and which it labels a terrorist organisation with the acronym Feto.
Mr Stoltenberg said he expected no change of heart. “There were security concerns that needed to be addressed," he said. "And we did what we always do at Nato. We found common ground.”
Every alliance nation has different legislative challenges and procedures to deal with and it could take several more months for the two to become official members.
“I look forward to a swift ratification process,” said Finnish Foreign Minister Pekka Haavisto. The Russian invasion of Ukraine has given the process added urgency. It will ensconce the two nations in the western military alliance and provide Nato with more clout, especially in the face of Moscow’s military threat.
Tuesday’s signing has brought both nations deeper into Nato’s fold already. As close partners, they already attended some meetings involving issues that immediately affected them. As they were officially invited, they can attend all meetings of the ambassadors even if they do not yet have any voting rights.