On Wednesday, NATO partner Turkey withdrew its opposition over Sweden and Finland's bid to be part of the Western alliance after the three states pledged to protect each other's security.

The withdrawal marks the completion of a weeks-long drama that tested allied unity in the face of Russia's invasion of Ukraine. 

It also means Helsinki and Stockholm can move forward with their application to join the nuclear-armed alliance, solidifying what is seen to be the most significant shift in European security in decades, as the two long-neutral Nordic nations seek NATO protection.

The change took place after four hours of talks just before a NATO summit in Madrid began, averting an embarrassing impasse at the gathering of 30 leaders that aims to demonstrate resolve against Russia, which is now viewed as a direct security threat rather than a potential adversary by the U.S.-led alliance.

"Our foreign ministers signed a trilateral pact confirming that Turkey will... support Finland and Sweden's invitation to join NATO," said Finnish President Sauli Niinistö in a statement.

Niinisto stated that the processes for Finland and Sweden's accession to NATO will be agreed upon within the next two days.

After discussions between NATO Secretary-General Jens Stoltenberg, Turkish President Recep Tayyip Erdogan, Swedish Prime Minister Magdalena Andersson, and Niinisto, Stoltenberg and Erdogan issued separate statements confirming the agreement.

"Sweden, Finland, and Turkey have recently reached an important agreement. opens the way for Sweden to join NATO," Andersson announced the news on Twitter.

The settlement of the impasse strengthens the alliance's reaction to Russia, especially in the Baltic Sea, where Finnish and Swedish membership would confer military superiority on NATO.

Denmark, Norway, and the three Baltic republics are already NATO members in the broader Nordic region. Russia's conflict in Ukraine, which Moscow refers to as a "special military operation," contributed to Sweden's decision to join NATO after decades of rejection.

United States President Joe Biden and Prime Minister Boris Johnson of the United Kingdom praised the agreement.

In a tweet, Biden referred to it as a "crucial step towards inviting Finland and Sweden to NATO, which would strengthen our alliance and enhance our collective security."

Stoltenberg stated that NATO's 30 leaders would now officially ask Finland, which shares a 1,300-kilometer border with Russia, and Sweden to join the alliance.

"The door is open - Finland and Sweden will join NATO," he told reporters.