SKOPJE, Macedonia (AP) — Macedonia and neighboring Bulgaria signed a landmark friendship agreement Tuesday that is designed to dampen a historic rivalry in a section of the Balkans where many countries remain at odds over old ethnic and territorial disputes.

Under the deal, both countries renounce territorial claims against each other and pledge to not engage in or back hostile acts against the other. It also commits Bulgaria to backing its smaller neighbor's bids to join the European Union and NATO.

European Union and German officials warmly hailed the agreement. EU foreign policy chief Federica Mogherini and enlargement commissioner Johannes Hahn said in a joint statement the treaty "is an inspiration for the whole region."

The treaty also calls for a committee to "objectively" re-examine the common history of Bulgaria and Macedonia, a process that could lead to a review of school textbooks.

Macedonia's conservative opposition denounced the agreement — signed in Macedonia's capital, Skopje, by Prime Minister Zoran Zaev and Bulgarian Prime Minister Boiko Borisov — as an act of "capitulation" to Bulgaria. The VMRO-DPMNE party governed the country for a decade before it was replaced Zaev's left-led coalition this year.

The party said it would not ratify the treaty in parliament, arguing that it would harm Macedonia's national interests on grounds including history, language and national identity.

Bulgaria historically regarded Macedonians and their language as a branch of the Bulgarian nation and language.

While the country was among the first to recognize Macedonia's independence from the former Yugoslavia in 1990, it angered Macedonia by refusing to recognize a Macedonian ethnic minority within Bulgaria. It also threatened to block its neighbor's EU and NATO accession drives.

Borisov said the treaty would seek to overcome the past.

"If you look back, you will stumble and fall," he said. "So we decided to look ahead. I am convinced that in 10 years the results will be visible."

German Foreign Minister Sigmar Gabriel said it was "remarkable" the treaty was signed less than two months after Zaev's new administration took office. Gabriel said he is counting on the government to "continue pursuing this form of constructive cooperation with all its neighbors."

Out of the five countries with which it shares borders, Macedonia only gets along well with Kosovo, although its recognition of the former Yugoslav province soured ties with another neighbor, Serbia.

A 27-year-old dispute has led southern neighbor Greece to block Macedonia's NATO accession bid. Greece says Macedonia's name — combined with nationalist aspirations — implies a claim on the northern Greek border province of Macedonia.

Macedonia is also on a shaky footing with Albania. An armed insurrection in 2001 by ethnic Albanians, who make up about a quarter of Macedonia's 2.1 million inhabitants, brought the country to the brink of civil war.

___

Geir Moulson in Berlin and Nicholas Paphitis in Athens contributed.