Germany's highest court has ruled that some of the powers granted to the country's federal police to fight terrorism are too broadly defined, but says they can largely still be used while the government makes revisions.

Since 2009, the Federal Criminal Police Office has had powers such as bugging homes of suspects, tapping phones and installing surveillance cameras. A former interior minister and several opposition politicians challenged the new rules.

The Federal Constitutional Court ruled Wednesday that those powers are largely in line with the constitution but the way they are defined doesn't always respect the "need for proportionality" and is sometimes too vague.

It gave the government until June 2018 to make amendments, adding safeguards to ensure that the gathering and use of data is better supervised.