HELSINKI (AP) — The Finnish president on Thursday formally sealed the Nordic country’s historic bid to join NATO by signing into law the required national legal amendments needed for membership in the Western military alliance.

The move by President Sauli Niinistö means Finland has completed national measures needed to join NATO, and is now just awaiting approval from Turkey and Hungary, the only two of NATO’s 30 existing members that haven't ratified its bid.

Admitting new countries requires unanimous approval from the alliance members, and the parliaments in Ankara and Budapest haven’t yet given the green light.

Last week Niinistö visited Ankara, where Turkish President Recep Tayyip Erdogan pledged to move forward with ratifying Finland’s application. That is expected before Turkey holds presidential and parliamentary elections scheduled for May 14.

After delays of several months, the Hungarian parliament is finally expected to approve the Finnish accession into NATO on March 27.

Finland’s 200-seat Eduskunta legislature endorsed the country’s NATO bid with an overwhelming 184-7 majority on March 1.

Finland and neighboring Sweden applied to become NATO members 10 months ago in the wake of Russia’s invasion of Ukraine, abandoning decades of nonalignment.

This is seen by many experts as one of the biggest geopolitical ramifications of Moscow’s war in Ukraine. Finland's border with Russia runs for a total of 1,340 kilometers (832 miles).

Finland and Sweden, which are close partners culturally, economically and politically, submitted their bids together and planned to enter the alliance at the same time.

Sweden’s accession, however, has stalled due to opposition from Turkey, and Erdogan said last week his country wouldn’t ratify it before disputes between Ankara and Stockholm are solved. It isn’t clear either when Budapest will ratify Stockholm’s bid.

On Wednesday, Swedish lawmakers overwhelmingly voted in favor of Sweden joining NATO, signing off on the country’s membership along with the required legislation.