Immigration and Customs Enforcement officials emphatically denied that charge, saying that the arrests had been planned since April. (The identity-card program, believed to be the first of its kind in the nation, was first suggested by Mr. DeStefano in 2005.)

The details of the arrests are still somewhat unclear. Federal officials said that they were “targeting fugitives,” not conducting a widespread sweep. Twenty nine men and two women — most of them from Mexico, Guatemala, Nicaragua, Guinea and Ecuador — were arrested. City officials said on Thursday that of the 16 arrest warrants the federal agents had, only four were executed, meaning that most of the 31 arrested were swept up in what they called a dragnet, and that 12 people the federal officials were looking for remained at large.

Image Immigrants and their advocates met Thursday outside a church in New Haven. Credit... Douglas Healey for The New York Times

Lawyers and advocates for immigrants who interviewed several relatives of those who were arrested said that in most cases, the immigration officials knocked on their doors and demanded to speak with every adult in the house, then asked for identification.

In several instances, they said, the agents separated the men from the women and asked which of the women had children. Those who did were left behind, while those who did not were taken into custody, the advocates said.

Immigration and Customs Enforcement officials have conducted hundreds of similar sweeps in the last year. In 2006, a spokesman said, they deported more than 221,000 illegal immigrants, many of them after proceedings that began with such arrests. Last fall, an operation in Danbury led to the arrest of 11 men who worked at a local factory.

Immigration advocates in Connecticut were fond of referring to Danbury and New Haven as two poles on the spectrum — the same immigrants who were shunned in the former were welcomed in the latter.