But the measure made the possession, use or cultivation of the mushrooms by people aged 21 or older the lowest-priority crime for law enforcement in the city of Denver and Denver County. Arrests and prosecutions, already fairly rare, would all but disappear.

Results posted by the city as a “final unofficial” tally late on Wednesday showed the “Yes” vote won by less than 2,000 ballots. The “No” vote had led throughout the day, until the last updated count by elections officials. Alton P. Dillard, the elections spokesman, said the passage appeared safe, but the final results would not be certified until May 16.

“We won!!!!” the group called Decriminalize Denver that had been pushing the measure, said in a jubilant post on Facebook.

Adoption of the measure, by a margin so close that the measure was initially thought to have been rejected, signaled fledgling public acceptance of a mind-altering drug, outlawed nationally for nearly 50 years, that recent research suggests could have beneficial medical uses.