A federal judge said Tuesday he intends to order Google Inc. (GOOG)to turn over some of its Internet records to the U.S. Justice Department, but expressed reservations about requiring the company to divulge some of its most sensitive data — the actual requests that people enter into its popular search engine.

U.S. District Judge James Ware told the Justice Department it can expect to get at least some of the information sought from Google as part of the Bush administration's effort to revive a law meant to shield children from online pornography.

But Ware stressed he was "particularly concerned" about the Justice Department's demand for a random sample of search requests entered into Google's Internet-leading search engine.

The judge said he didn't want to do anything to create the perception that Internet search engines and other large online databases could become tools for government surveillance. He seemed less concerned about requiring Google to supply the government with a random list of Web sites indexed by the company.

Ware said he planned to issue a written ruling quickly.

After the 90-minute hearing, Google attorney Nicole Wong said the company was pleased with Ware's thoughtful questions.

Justice Department spokesman Charles Miller said the agency looks forward to Ware's decision. "We hope his opinion will demonstrate the government's belief that this info would be helpful in protecting the nation's youth against potentially harmful material," he said.

During the hearing, another Google attorney, Albert Gidari, tried to persuade Ware that the government could get virtually all the information it wanted from publicly accessible services offered by Amazon.com Inc.'s Alexa.com and InfoSpace Inc.'s Dogpile.com.

T. Barton Carter, a communications and law professor at Boston University, said the concerns raised by Ware should be heartening to privacy rights advocates, but cautioned against reading too much into the judge's comments until his written order.

"What's going to be important is whether he limits the information (given to the government) and whether he explains why he drew the line where he did," Carter said.

Investors seemed encouraged by Tuesday's developments as Google's recently slumping stock price surged $14.10, or 4.2 percent, to close at $351.16 on the Nasdaq Stock Market.

Tuesday marked the first time that Google and the Justice Department have faced off in court over a government subpoena issued nearly seven months ago. The Justice Department initially wanted a breakdown of search requests and Web site addresses from Google for a study that the government believes will prove filtering software doesn't prevent children from viewing sexually explicit material on the Internet.

Google refused to hand over the information, even as three other major search engines turned over some of the requested data. Mountain View-based Google maintained the government's request would intrude on its users' privacy and its trade secrets.

Google's protests prompted the government to scale back its requests dramatically. Justice Department attorney Joel McElvain told Ware Tuesday that the government now wants a random sampling of 50,000 Web site addresses indexed by Google and the text of 5,000 random search requests.

McElvain said just 10,000 of the Web sites and 1,000 of the search requests would be used in a study for a Pennsylvania case revolving around the online child pornography law that has been blocked by the U.S. Supreme Court. That case is scheduled for an Oct. 23 trial.

The Justice Department plans to use the search requests to show how easy it is for online pornographers to fool Internet filters, hoping that it will help demonstrate the need for a tougher law to protect children from the material.

The government's scaled-back requests have minimized Google's concerns about sharing confidential company information, but the privacy issues remain troublesome, Gidari told Ware.

Although the government doesn't want Google to turn over anything that would identify a person making a search request, Gidari said the content of certain queries often contains sensitive information about finances, Social Security numbers and sexual preferences.

Indicating he was thinking about only granting part of the government's request, Ware asked Gidari if Google would rather hand over the Web site addresses or a list of people's search requests. Without providing a definitive answer, Gidari said Google believed an order requiring the company to surrender people's search requests would have a "chilling effect" on the Internet.

Steve Mansfield, chief executive of a recently launched search engine called PreFound.com, said the entire industry will get a lift if Ware prevents the government from getting a glimpse at Google's search requests.

"This entire case has become about public perception," Mansfield said. "If people perceive that what they are putting into a search engine isn't private, that's going to be a big negative for everyone."

Pressed by Ware, McElvain acknowledged the Justice Department had already obtained enough information from other search engines to conduct its study. "But the study would be improved with Google's data," he said.

Yahoo Inc.(YHOO), Microsoft Corp.'s (MSFT) MSN and Time Warner Inc.'s (TWX) AOL have turned over some search engine information to the Justice Department. All three companies said they complied with the government subpoena without compromising their users' privacy.

The government will have to reimburse Google for whatever costs that the company incurs. Google has estimated it will take its engineers five to eight days to extract the data requested by the Justice Department.