The constitutional court was ruling on suits brought by a former interior minister, Gerhart Baum, members of the Greens party, lawyers, a journalist and a doctor.

They had voiced concerns that covert surveillance, particularly in private homes and in the intimacy of bedrooms or bathrooms, could entangle innocent third parties. There were also worries that surveillance could violate professional confidence through the monitoring, for example, of conversations by suspects with their doctors or lawyers, or with members of Parliament.

“In some respects,” the court’s ruling said, “the current design of the investigative powers does not satisfy the principle of proportionality.” As a result, the provisions governing covert surveillance “are in part too vague and too broad,” it said.

It called for the creation of an unspecified “independent body” that would examine data before it was passed to the federal police, or to foreign institutions.

Ruling for the first time on the transfer of intelligence data to third countries, the court said that such transfers outside the 28-nation European Union must conform to the German Constitution.

“What is required is the guarantee of an appropriate, substantive level of data protection for the handling of the transferred data in the receiving state,” the ruling said.

The two judges who dissented from the majority decision said that the court had gone too far in trying to regulate surveillance and intelligence data, and that it should leave this to lawmakers.