In the Greek village of Pisoderi, protesters carried a giant Greek flag and one group clashed with riot police on a mountain slope as they tried to break the cordon.
"Traitors, traitors", up to 5,000 protesters gathered in the central Syntagma square chanted.
Greece's Prime Minister Alexis Tsipras and his Macedonian counterpart Zoran Zaev attended the signing ceremony at the Greek village of Psarades, on the shores of Greater Prespa Lake, a site chosen because it is near where the borders of the two countries, as well as Albania, meet.
The agreement aimed to end a bitter dispute between the two countries that has been running since shortly after Macedonia declared independence in 1991.
Under the deal, the country known at the United Nations as Former Yugoslav Republic of Macedonia (Fyrom) would be named Severna Makedonija, or Republic of North Macedonia. In Athens, Tsipras survived a no-confidence vote over the agreement on Saturday.
A vote on the motion is expected later on Saturday.
Many Greeks are opposed to Skopje's use of the name Macedonia, as they say, it appropriates Greek history and fails to distinguish itself from the Greek region with the same name.
Greece in return will suspend the objections that prevented Macedonia from joining North Atlantic Treaty Organisation and the European Union. That approval is far from assured, as it faces stiff opposition from the Greek public, and Macedonia's president has vowed to block the deal.
Later in the day, at least eight people were injured when Greek police used tear gas at protesters near the ceremony area, local media reported.
United States child migrants: Melania calls for end to Trump's separation policy
The separations stem from a deliberate policy shift by the Trump administration , which it has the power to unilaterally reverse. Attorney Jeff Sessions spoke on immigration policy and law enforcement actions, Friday , June 15, 2018, in Scranton, Pa.
Conservative New Democracy party leader Kyriakos Mitsotakis, who had brought the no-confidence motion, argued that a vote in favour of the government was a vote in favour of the name deal.
While the European Union and the United Nations welcomed the agreement, thousands of Greek protesters rallied outside Greece's Parliament building, accusing the prime minister of being a "traitor", according to Reuters.
"With the signing of the agreement between Macedonia and Greece, everyone will benefit", Zaev said on Saturday.
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.
"Ultimately they are for sale", the 2016 Olympics 25-metre pistol gold victor said in an Instagram posting with the hashtag "betrayal", apparently referring to the name and identity of Macedonia.
Daily protests have also been held in Skopje in front of the parliament since Zaev announced on June 12 he had reached the deal with Tsipras. "We are there thanks to the dedication, commitment, courage, leadership and hope that both Prime Ministers have put into this process", she said.
In the Republic of Macedonia, Parliament should consider a bill of ratification within a week.
"We are Macedonians and we will always be Macedonians", said an elderly man.
The accord still has to be approved by both countries' parliaments and pass in a referendum in Macedonia.