Turkey has lifted its opposition to Sweden and Finland joining NATO, Secretary General Jens Stoltenberg confirmed Tuesday. 

The momentous breakthrough came during a leader’s summit in Madrid this week, as Russia’s ongoing invasion of Ukraine overshadows Europe.   

Turkey Sweden Finland NATO

From left to right background: NATO Secretary General Jens Stoltenberg, Turkish President Recep Tayyip Erdogan, Finland's President Sauli Niinisto, Sweden's Prime Minister Magdalena Andersson, Turkish Foreign Minister Mevlut Cavusoglu, Finnish Foreign Minister Pekka Haavisto, and Sweden's Foreign Minister Ann Linde sign a memorandum in which Turkey agrees to Finland and Sweden's membership of the defense alliance in Madrid, Spain on Tuesday, June 28, 2022.  (AP Photo/Bernat Armangue)

"[W]e now have an agreement that paves the way for Finland and Sweden to join NATO," Stoltenberg said after urgent top-level talks. 

The war in Ukraine has prompted Sweden and Finland to abandon their long-held nonaligned status and apply to join NATO. Turkish President Recep Tayyip Erdogan blocked the move because of the Nordic countries’ support of Kurdish rebel group that Turkey considers terrorists.

ALEXEI NAVALNY APPEAL REJECTED BY RUSSIAN COURT

Finnish President Sauli Niinistö said the three countries' leaders signed a joint agreement after talks on Tuesday.

Turkey said it had "got what it wanted" including "full cooperation ... in the fight against" the rebel groups.

Stoltenberg, speaking at the opening of a crucial summit, said the meeting would chart a blueprint for the alliance "in a more dangerous and unpredictable world."

"To be able to defend in a more dangerous world we have to invest more in our defense," Stoltenberg said. 

RUSSIA FIRED ROCKETS AT UKRAINE MALL CONTAINING ‘MORE THAN A THOUSAND CIVILIANS,’ ZELENSKYY SAYS

President Biden praised the agreement, calling it a "crucial step towards a NATO invited to Finland and Sweden, which will strengthen our Alliance and bolster our collective security – and a great way to begin the Summit." 

Moscow's invasion on Feb. 24 shattered European security and brought shelling of cities and bloody ground battles back to the continent. NATO, which had begun to turn its focus to terrorism and other non-state threats, has had to confront an adversarial Russia once again.

Turkey President Erdogan

Turkish President Recep Tayyip Erdogan, second left, and NATO Secretary General Jens Stoltenberg before signing a memorandum in which Turkey agrees to Finland and Sweden's membership of the defense alliance in Madrid, Spain on Tuesday, June 28, 2022.  (AP Photo/Bernat Armangue)

Diplomats and leaders from Turkey, Sweden and Finland earlier held a flurry of talks in an attempt to break the impasse over Turkey's opposition to expansion. The three countries' leaders met for more than two hours alongside Stoltenberg on Tuesday before the agreement was announced.

KHERSON MAYOR ABDUCTED BY RUSSIAN FORCES AFTER REFUSING TO FLEE OCCUPIED CITY

Erdogan is critical of what he considers the lax approach of Sweden and Finland toward groups that Ankara deems national security threats, including the Kurdistan Workers' Party, or PKK, and its Syrian extension. American support for Syrian Kurdish fighters in combating ISIS has enraged Turkey for years.

Turkey, meanwhile, has demanded that Finland and Sweden extradite wanted individuals and lift arms restrictions imposed after Turkey's 2019 military incursion into northeast Syria.

Ending the deadlock will allow NATO leaders to focus on their key issue: an increasingly unpredictable and aggressive Russia.

CLICK HERE TO GET THE FOX NEWS APP

Stoltenberg said Monday that NATO allies will agree at the summit to increase the strength of the alliance's rapid reaction force nearly eightfold, from 40,000 to 300,000 troops. The troops will be based in their home nations, but dedicated to specific countries on NATO's eastern flank, where the alliance plans to build up stocks of equipment and ammunition.

The Associated Press contributed to this report.