The Constitutional Court in Russia's Ingushetia region has ruled that a law designed to support a controversial border agreement with neighboring Chechnya is illegal.

The October 30 ruling adds to the uncertainty over the fate of the deal, which mandated land swaps between the two North Caucasus republics and has prompted angry protests in Ingushetia.

On its website, the court said that the law was illegal because "it changes the territory of the Republic of Ingushetia," something it said required approval by referendum.

But the head of Ingushetia, Yunus-Bek Yevkurov, said that the court decision did not render the pact with Chechnya invalid and that only the Russian Constitutional Court in Moscow should have the authority to rule on the agreement.

"It's necessary to understand that today's ruling does not cancel the agreement -- it has entered into legal force," Yevkurov told journalists.

The agreement on the administrative boundary was signed behind closed doors on September 26 by Yevkurov and Ramzan Kadyrov, the leader of Chechnya.

The deal sparked large, persistent protests in Ingushetia by opponents who say the deal unfairly hands parts of the region to Chechnya, its larger neighbor to the east.

Protesters have called for Yevkurov's resignation and a referendum on the deal, which officials announced was approved by the parliaments of both regions several days later.

Some Ingushetian lawmakers said later that the legislature had not approved the deal.

The dispute has raised the specter of regional conflict in Russia, a huge country that is home to a large number of ethnic groups, and amplified concerns about the Kremlin-backed Kadyrov's power and influence.

Kadyrov has publicly threatened the protesters in Ingushetia, and there was tension on October 26 when he brought a large entourage into Ingushetia to meet with a protest leader, but the meeting ended peacefully.

Ingushetia and Chechnya were parts of a single administrative region in the Soviet era and split after the 1991 Soviet collapse.

Concerns about losing territory are strong in Ingushetia, which lost control of the disputed Prigorodny district to another neighbor, North Ossetia, following a conflict in 1992 that left some 600 people dead, predominantly Ingush.

Rights activists say that Kadyrov, who was appointed to head Chechnya by President Vladimir Putin in 2007, rules through repressive measures and has created a climate of impunity for security forces in the province.

Kremlin critics contend that Putin has given Kadyrov free rein because he relies on him to keep a lid on separatism and insurgent violence after two devastating post-Soviet wars in the region.

With reporting by RFE/RL's Russian Service and Interfax