The plaintiffs in the case accused the two German companies, as well as U.S. firms Ford Motor and IBM, of facilitating race-based crimes by selling products such as cars and computers to South African security forces during apartheid.
U.S. District Judge Shira Scheindlin in New York said the German companies could not be sued under a 1789 law, the Alien Tort Statute, allowing non-U.S. citizens to bring cases in U.S. courts over violations of international law.
Scheindlin said the plaintiffs failed to show that the facts of the case "touch and concern the United States with sufficient force" to justify the law's use.
She declined, however, to immediately dismiss related claims against Ford and IBM.
Those companies had pushed for dismissal after a federal appeals court in August sent the case back to Scheindlin for a decision, while opining that the claims appeared "plainly barred" by a recent Supreme Court ruling.
"I think this came as a shocker to Ford and IBM," said Michael Hausfeld, a lawyer for the plaintiffs.
The plaintiffs include South Africans and family members who said they were victims of decades of race-based crimes, including torture and extrajudicial killings, by South African security during apartheid.
Apartheid ended in 1994 when South Africa held its first all-race elections, bringing Nelson Mandela and the African National Congress to power. Mandela died Dec. 5.
Both Robert Zimet, a lawyer for Rheinmettal, and Han Tjan, a spokesman for Daimler, welcomed the ruling.
"We are hopeful that this ruling will put a final end to this litigation that went on for over 10 years," Tjan said.