Tuesday’s decision was the third in a series of Supreme Court cases considering whether a given state drug crime amounted to an aggravated felony under the immigration laws. If it does, the government has no choice but to deport the defendant. If it does not, the attorney general has the discretion to show leniency.

The question in all of the cases was how to understand state drug convictions in light of a part of the immigration laws that defines aggravated felonies to include drug offenses that would be punishable by more than a year in prison under the federal Controlled Substances Act.

The act generally calls for a maximum term of five years for possessing controlled substances with an intent to distribute them. But it contains an exception for the distribution of “a small amount of marijuana for no remuneration,” which judges may treat as a misdemeanor subject to no more than a year in prison.

Justice Sotomayor wrote that it was not clear whether the formal elements of Mr. Moncrieffe’s state conviction fit within the federal exception. The ambiguity, she said, counted in his favor, sparing him from automatic deportation.

The federal government said the actual facts of the case mattered and should be determined during immigration proceedings. Justice Sotomayor rejected that approach, saying that “our nation’s overburdened immigration courts” would have difficulty making such determinations based on stale or missing evidence presented by immigrants who may be in detention and have no right to a lawyer.