Google should "confer" with the government to develop a protocol to randomly select and provide the URLs from its index, but to comply with this order Google doesn't have to disclose proprietary information about its Web site address database, the judge wrote.
Moreover, the government needs to pay Google for the cost of producing this data, and the data will be kept under wraps by the court's order.
Finally, the government's request for a sample of search queries filed by Google users was denied.
"This is a clear victory for our users and for our company, and Judge Ware's decision regarding search queries is especially important. While privacy was not the most significant legal issue in this case (because the government wasn't asking for personally identifiable information), privacy was perhaps the most significant to our users," said Nicole Wong, Google's associate general counsel, in a statement Friday.
The Justice Department wants Google to provide a week's worth of search records, saying it needs the data to help it better police cyberspace.
But Google complained that complying with the request would compromise its business and the privacy of its users.
Similar requests were made of other net firms such as Microsoft, Yahoo and AOL.
The US government is seeking to defend the 1998 Child Online Protection Act, which has been blocked by the Supreme Court because of legal challenges over how it is enforced.
It wants the data from the search engines to prove how easy it is to stumble over porn on the net.