SKOPJE (Reuters) - The leaders of Greece and North Macedonia hugged, took selfies and signed a new agreement for air patrols on Wednesday in a display of newly-friendly relations since a nearly three-decade name dispute was settled earlier this year.

North Macedonia’s Prime Minister Zoran Zaev was all smiles as his counterpart Alexis Tsipras became the first Greek prime minister to pay an official visit to the ex-Yugoslav republic since it declared independence in 1991.

The pair struck a deal last year for Macedonia to be re-named North Macedonia - satisfying Greece’s longstanding complaint over an implied claim to its province also called Macedonia - and the change came into force in January.

The deal has opened the way for North Macedonia to seek membership of the European Union and NATO blocs.

Upon arrival, Tsipras and Zaev snapped selfies, while the Greek leader’s wife was presented with flowers.

The two prime ministers discussed infrastructure projects including improving a railway between the Macedonian capital Skopje and Greek port Thessaloniki.

“We are writing history,” Zaev said.

Slideshow ( 9 images )

“You are looking at two neighbors, friendly people who have shown Europe and the entire world that with brave decisions and good wishes for togetherness, something that was impossible yesterday has become reality today.”

“SILLY BEHAVIOR STOPS”

They agreed to cooperate in their defense industries, cyber protection and military intelligence.

Macedonia, which has no fighter jets, will also allow Greece to patrol its skies for the first time.

Calling Zaev his “dearest friend”, Tsipras said it was time to make up for nearly three “lost” decades.

“For years, every time I would go to Europe with the government aircraft ... I noticed that the pilot made a deviation so it wouldn’t enter the airspace of FYROM (Former Yugoslav Republic Macedonia),” he said.

Slideshow ( 9 images )

“This silly behavior now stops .. Not only won’t we make deviations, but we might also take a stroll to say hello.”

Zaev reiterated that NATO and EU membership were the priorities for his tiny Balkan state. “But we also want cooperation with Russia, China and the Eastern world,” he said.

The dispute had been on the United Nations’ agenda ever since the former Yugoslavia broke up in 1991 and Greece, swept up by nationalist rage, had slapped a short-lived trade embargo on the landlocked state.

EU commissioner for enlargement Johannes Hahn tweeted his congratulations, praising the pair for putting citizens and the region first. “Their courage and vision is a signal to the rest of South East Europe that hard nuts can be cracked,” he said.