"We will not divide the Greeks in order to unite the (Macedonians)", he said.
At least six people were hurt. However, top European Union top officials have said that the signing of the deal by the president would not be crucial for Macedonia to obtain a date to start European Union talks once it is ratified in the parliament.
In a joint appearance with FYROM premier Zoran Zaev, Greek Prime Minister Alexis Tsipras described the agreement as "patriotic and mutually beneficial", and stressed the importance of safeguarding it.
"We are here to heal the wounds of time, to open a path for peace, fraternization and growth for our countries, the Balkans and Europe", he said, adding that the time had come again "to sing happy songs in the Balkans". "We put an end to the long-standing differences which have put up a wall that made friendly relations hard between neighbours", Zaev said. "By signing the agreement. we have really moved mountains".
We have a historic responsibility that this deal is not held in abeyance.The signing ceremony was attended by the United Nations secretary-general's personal envoy, Matthew Nimetz, and the EU's top diplomat, Federica Mogherini.
"Today is my birthday", said Nimetz, who turned 79 on Sunday.
It was the election of Zaev in 2017, an economist, that proved crucial to the agreement which could still unravel however.More news: A 'milestone' World Cup win kicks off celebration for Mexico
"This is a deal I believe that every Greek prime minister would want", Mr Tsipras told the chamber earlier.
The Macedonian-Greek dispute, which emerged after Macedonia declared independence from former Yugoslavia back in 1991, erupted because of fears in Athens that newly independent Macedonia might claim territories gained by Greece following the Second Balkan war in 1913.
The two premiers, born just months apart in 1974, have bucked strong hostile reactions at home to push ahead with the agreement.
Thus, as a result of signing the historic Pact, Macedonia has been renamed the Republic of Northern Macedonia.
Protesters clash with police in Athens, Greece.
Things have been complicated further as Macedonia's President Gjorge Ivanov is refusing to sign the agreement as he has the power to veto the deal.
- Both countries confirm their common existing frontier as their "enduring and inviolable worldwide border".More news: Rapper XXXTentacion Dead at 20 After Being Shot in Miami
The agreement still needs to be approved by Macedonia's parliament and pass a referendum.
In Greece, the deal faces ratification in parliament only after Macedonia has completed its part of the process.
They argue that by officially recognizing a Macedonian language and nationality, it is nearly certain that the country will be called Macedonia by the broader world, instead of North Macedonia.
Greece also has a region called Macedonia.
Under the deal, Greece's neighbour will be known as North Macedonia.
Negotiations between Macedonia and Greece had recently stepped up, as the new government in Skopje sought progress in its bid to join North Atlantic Treaty Organisation and the EU.More news: FIFA 2018: Russia sour Salah's return to close in on last 16