The officer questioned Mr. Ramírez, a 21-year-old Mexican who acknowledged that he was in the country illegally, and the New Ipswich police tried to get federal immigration authorities to arrest him. But when immigration officials demurred, not considering him a priority given scarce enforcement resources, the police acted on their own. They took the highly unusual step of charging Mr. Ramírez with criminal trespassing, and held him overnight.
"I wanted the federal government to understand that I was going to take some type of action," said the New Ipswich police chief, W. Garrett Chamberlain. "If I can discourage illegal aliens from coming to or passing through my community, then I think I've succeeded."
At a minimum, Chief Chamberlain has succeeded in creating controversy, as well as interest in his idea. Not far away, the police chief in Hudson, N.H., has charged 10 illegal immigrants with criminal trespassing in recent weeks. Other police departments, in states that include California, Florida and Georgia, have called Chief Chamberlain, and immigration experts say that if the New Hampshire charges are upheld, some local law enforcement officials around the country will most likely copy the approach.
The case against Mr. Ramírez, who lives in Waltham, Mass., and was working as a construction worker here in Jaffrey when he was charged, is also being watched by civil liberties advocates and the Mexican government, which is paying for his lawyers. The matter went to court on Tuesday in Jaffrey/Peterborough District Court, where the defense asked Judge L. Phillips Runyon III to dismiss the case, arguing that immigration enforcement was the federal government's job and that the New Hampshire criminal trespassing statute was intended to apply to those intruding on private property, not to illegal immigrants.
"What the state is attempting to do here is to step into the federal government's shoes and determine whether a person is licensed or able to remain in the United States," said one defense lawyer, Randall Drew.
The prosecutor, Nicole Morse, argued that local police agencies had a right to cite illegal immigrants.
"Just as with a sex offender," Ms. Morse said, "the hope is that they will go and register with the state. And if they don't, then they are violating the law.
"Indeed, the state's interest in this case is security. Being able to identify people who are in our community is essential to the police being able to maintain and keep the peace."
Judge Runyon deferred his decision on whether to dismiss the case until he could hear similar motions in the cases from Hudson. But his questions to both sides underscored the combustible and sensitive nature of immigration enforcement in a post-9/11 world.
On the one hand, he said to defense lawyers, "in this day and age when everyone is so worried about having terrorists in our midst, if a local law enforcement person is dealing with somebody that can't show some basis for their lawfulness of being here," and "they can't get any kind of response that seems to answer their questions from Immigration, are they just hamstrung?"
On the other hand, he told the prosecutor, some immigrants might "have a driver's license from Germany or France but don't have any other papers" with them. "Are you suggesting that those people are going to be charged criminally," he said, "because the police can't figure out that they're supposed to be where they are?"
Noting that if Mr. Ramírez was found guilty, he would be sentenced to nothing more than a $1,000 fine, not jail time, the judge also asked the prosecutor, "How is national security or even local security enhanced by giving someone a citation?"
In a state that is 96 percent non-Hispanic white but that has been seeing a rise in its Hispanic population, Chief Chamberlain's idea was born a year ago when he encountered a van with nine illegal immigrants from Ecuador. The federal Bureau of Immigration and Customs Enforcement, he says, was not interested in arresting them. He decided that in the future he would use the state's criminal trespassing law, which says that a person is guilty "if, knowing he is not licensed or privileged to do so, he enters or remains in any place."
Even some critics of the New Hampshire citations, like Susan J. Cohen, a Boston immigration lawyer, said the law's broad language made it seem applicable to immigration.
Ms. Cohen said most states' criminal trespassing laws referred specifically to private property and could not be easily applied to immigration. But Kris W. Kobach, a law professor at the University of Missouri-Kansas City, who was counsel to John Ashcroft when Mr. Ashcroft was attorney general, said he believed that New Hampshire's wording was not unusual, and added that the charges were appropriate because the government "has always been careful to invite and encourage local assistance with immigration arrests."
Not every police department would take such a tack. In Nashua, N.H., which has a growing Hispanic population, the deputy police chief, Don Conley, said that "I don't think it's in the true spirit of New Hampshire's criminal trespass law."
Opponents like Arnie Alpert, New Hampshire coordinator of the American Friends Service Committee, say such citations will discourage immigrants, legal and illegal alike, from cooperating with police officers. And Porfirio Thierry Muńoz-Ledo, the Mexican consul general in Boston, who attended Tuesday's hearing, said, "The concern is that we are dealing in a state court with matters that belong to a federal level."
Judge Runyon seemed somewhat concerned about that as well.
"Am I going to determine whether someone is here legally or not?" he
asked the prosecutor. "Isn't that what the federal immigration system is
for? Is it for part-time district court judges like me who know nothing
about immigration and arguably nothing much about anything else either?"