The Federal Administrative Court threw out a challenge by the world's largest internet hub, the De-Cix exchange, against the tapping of its data flows by the BND foreign intelligence service.
The operator had argued the agency was breaking the law by capturing German domestic communications along with international data.
The court in the eastern city of Leipzig ruled that internet hubs "can be required by the federal interior ministry to assist with strategic communications surveillance by the BND".
De-Cix says its Frankfurt hub is the world's biggest internet exchange, bundling data flows from as far as China, Russia, the Middle East and Africa, which handles more than six terabytes per second at peak traffic.
It said that BND, a partner of the US National Security Agency (NSA), has placed so-called Y-piece prisms into its data-carrying fibre optic cables that give it an unfiltered and complete copy of the data flow.
The surveillance sifts through digital communications such as emails using specific search terms, which are then reviewed based on relevance.
De-Cix said in a statement that it believed the ruling shielded it from criminal liability for violations of the law protecting German domestic communications against tapping by stating that the German government bore responsibility. However it said it would review whether it would take its complaint to the Federal Constitutional Court.
Given the mass of daily phone calls, emails, chats, internet searches, streamed videos and other online communications, an effective fire-walling of purely German communications is unrealistic, activists argue.
Germany had reacted with outrage when information leaked by former NSA contractor Edward Snowden revealed in 2013 that US agents were carrying out widespread tapping worldwide, including of Chancellor Angela Merkel's mobile phone.
Merkel, who grew up in communist East Germany where state spying on citizens was rampant, repeatedly declared that "spying among friends is not on" while acknowledging Germany's reliance on the US in security matters. But to her great embarrassment, it later emerged that the BND helped the NSA spying on European allies.