Several election lawyers, including Burt Odelson, a longtime expert here in such matters, raised questions, and soon, a full challenge was under way; at one point, close to 30 people here had filed official complaints over the matter, but those numbers dwindled as the Chicago Board of Election Commissioners and a Cook County judge ruled on the question of residency in Mr. Emanuel’s favor.

Those close to Mr. Emanuel say he was aware of the residency requirement even before he chose to leave the White House in October to explore a run for mayor here. An associate said he had been advised by lawyers that the requirement would probably not be a serious obstacle. He believed that his biggest challenge would not be proving his legal residency, the associate said, but clearing the field of potential challengers and overcoming some liberal critics.

Legal experts have offered widely diverging views of what the state’s municipal code means when it refers to legal residency.

Supporters of Mr. Emanuel, who was born in Chicago and represented a Congressional district here for years, say legal residency is a matter of “intent” and whether he always intended to return from Washington after the White House  a circumstance they argue is backed up by his owning a house here (though a tenant has rented it for now), voting here, paying taxes here, and leaving his most prized possessions (including his wife’s wedding dress) here.

Others  including two of the Illinois appellate justices issuing the ruling on Monday  say that physical presence is needed, and that service at the White House provides no special exception.

Some here were hinting that they sensed old-school Chicago politics in the ruling, particularly in a state where judges are elected and local party leaders sometimes support them, but others dismissed such notions.

The appellate court justices who held the majority in the case  Thomas E. Hoffman and Shelvin Louise Marie Hall  have run as Democrats, court officials said, and Mr. Hoffman, who wrote the ruling and has served 17 years as an appellate judge, was widely lauded by colleagues for his past legal analyses.