NEW DELHI — India’s Supreme Court declared on Friday that a law pushed by the government of Prime Minister Narendra Modi that would have increased the executive branch’s power over the selection of judges was unconstitutional, a decision hailed as a landmark affirming the independence of the judiciary.

“If the alignment of tectonic plates on distribution of powers is disturbed, it will quake the Constitution,” Justice Kurian Joseph, one of five judges who heard the case, wrote in the ruling. “Once the constitutional structure is shaken, democracy collapses.”

But Friday’s decision was not without controversy, because it upheld a system of appointments to higher courts by a panel of judges, known as a collegium, that has been criticized for a lack of transparency.

India has a long tradition of a judiciary independent from the rest of the government, a situation reinforced by a Supreme Court decision in 1993 creating the collegium system and all but cutting the executive branch out of the selection process.