PARIS—France’s top constitutional court mostly upheld a new French surveillance law that would give intelligence services broad new powers to spy in France and abroad.

The court-backed provisions of the law allow a wide range of new surveillance techniques meant for the Internet age, including the collection of “metadata” about online traffic and the use of software that can monitor every keystroke on a computer. The court said intelligence services can use these tools without approval of a judge, though the government must...