SAN FRANCISCO  In a major victory for Google in its battle with media companies, a federal judge in New York on Wednesday threw out Viacom’s $1 billion copyright infringement lawsuit against Google’s YouTube, the No. 1 Internet video-sharing site.

The ruling in the closely watched case could have major implications for the scores of Internet sites, like YouTube and Facebook, that are largely built with content uploaded by their users.

The judge granted Google’s motion for summary judgment, saying the company was shielded from Viacom’s copyright claims by “safe harbor” provisions of the Digital Millennium Copyright Act.

Those provisions generally protect a Web site from liability for copyrighted material uploaded by its users as long as the operator of the site takes down the material when notified by its rightful owner that it was uploaded without permission.