Last winter, Montgomery J. Gray, a government contractor who lives in Arlington, got into a dispute with his bosses at the National Library of Medicine about which parts of the library's mainframe he was authorized to access.

Library officials called the FBI, which charged Gray with computer intrusion and got a warrant to seize four computers from his home and look for text and data downloaded from the library.

But when FBI agents searched through Gray's hard drives, they found something else: pornographic pictures in a directory labeled "tiny teen."

Now Gray, who goes on trial Tuesday in U.S. District Court in Alexandria, is looking at serious prison time. Computer intrusion is a misdemeanor carrying a maximum of a year in jail. But Gray, who is in his mid-fifties, could get up to five years if convicted on child pornography charges.

His case also puts him on the cusp of a hot new legal topic: How should courts balance the right to privacy and the need to fight crime in the world of information technology?

In the material world, courts have long held that law enforcement agents who have a warrant to search for evidence of a specific crime can seize evidence of another illegal activity if it is "in plain sight" or they encounter it during their authorized search.

In practice, that means that police officers looking for a gun used in a robbery can seize a bag of cocaine that's lying on a table or in a drawer where a gun would fit. But the Fourth Amendment's protection against "unreasonable search and seizure" means agents can't ransack someone's magazine collection while seeking a rifle.

Similarly, the Constitution and the 1986 Electronic Communications Privacy Act together prevent law enforcement officers from rummaging indiscriminately through computers or e-mail accounts, most agree. But what does "in plain sight" mean in the world of hard drives--or in the records of an Internet service provider?

"Our traditional Fourth Amendment thinking doesn't map well into high-tech information gathering," said University of Miami law professor A. Michael Froomkin.

The question is far from academic. As computer hard drives grow and ordinary people use e-mail for more and more of their communication, courts are having to deal with high-tech searches in a variety of contexts.

"Everybody has a computer. It used to be documents. Now drug dealers have laptops and Palm Pilots," said Scott Larson, an FBI supervisory special agent who heads the Washington field office's computer intrusion squad. "Data is much more complicated than the real world. . . . We try to be conservative and get warrants" for searching computers or requesting records from Internet service providers.

But privacy advocates complain that authorities regularly push the boundaries of legitimate searches and that judges are only beginning to draw clear lines.

"So much of it is done behind closed doors that it is difficult to monitor," said lawyer Christopher Wolf, who defended a gay sailor last year when the Navy tried to discharge him based on information that investigators had obtained from America Online without a warrant.

In that case, a federal judge ruled that the Navy couldn't use the fact that Timothy R. McVeigh wrote an anonymous AOL profile in which he described himself as gay.

This year, several appeals courts have had to struggle with the limits of "plain sight."

In February, the 1st U.S. Circuit Court of Appeals ruled that an officer investigating an assault on a Maine woman could not troll through a computer belonging to her neighbor simply because the background of the man's computer screen displayed a woman in bondage.

The 10th Circuit said in April that Kansas police could not use child pornography images they found on Patrick Carey's computer while seeking information about drug dealing because detectives abandoned their original, legal search and shifted to a warrantless hunt for pornography.

Now the issue has come to the Washington area with a new twist.

FBI agent Arthur Ehuan, who searched Gray's computer, was aware of the Carey case, so as soon as he saw what looked like nude children, he stopped his search. Then the FBI used that picture to get a second warrant to search for pornography.

But Gray's attorney, Peter D. Greenspun, argued at a recent hearing that Ehuan shouldn't have opened the first picture because the original warrant sought text and data, not photography.

The pictures were clearly marked as image files, Greenspun argued. And even if they had been mislabeled, there are software programs that could have told Ehuan whether text was hidden inside despite the label, Greenspun said.

"We're not talking about rocket science computer programs," Greenspun said in court. "They have a responsibility to at least inquire what is the least intrusive means" of searching.

Some lawyers agreed, saying the government can't demand all paper files without regard to subject, so agents shouldn't be allowed to open every computer file.

"At least they should have [computer programs] to find phrases that are relevant to the search," said University of Florida law professor Christopher Slobogin.

U.S. District Judge T.S. Ellis III ruled that Ehuan had acted responsibly by seeking the second warrant and that the FBI isn't obligated to use the most up-to-date method of searching for files. "I don't think what he did was unreasonable," Ellis said.

But he acknowledged that the rules in this area are still in flux.

"This is evolving on a weekly basis, and if you see something the court has overlooked, you are welcome to draw it to the court's attention and ask for a reconsideration," the judge told Greenspun.