Massachusetts voters approved a referendum in November that decriminalized small amounts of marijuana, but the change does not apply to federal property.

Sullivan, who lives in Washington but owns a home in Provincetown, was stopped by a park ranger for smoking marijuana on the beach shortly before 3:45 p.m. When the ranger asked Sullivan if he had any other joints, the writer fished one out of his wallet and said, “I thought small amounts of marijuana were legal to have in Massachusetts,’’ according to court records.

Collings’s ruling stems from an otherwise unremarkable event on the Cape Cod National Seashore on July 13.

Sullivan, 46, declined to comment in an e-mail. A self-described libertarian conservative, Sullivan is well known for his idiosyncratic views. Catholic and openly gay, he is a strong proponent of same-sex marriage and has denounced restrictions on medical marijuana in his Daily Dish blog on The Atlantic Online.

Brandy Donini -Melanson, a spokeswoman for the US attorney’s office, said yesterday that Loucks had no comment on the matter.

Collings added with obvious irritation that he had no power to order prosecutors to pursue the case, and granted their motion to dismiss it. The fact that he did, however, “does not require the Court to believe that the end result is a just one,’’ he wrote.

“It is quite apparent that Mr. Sullivan is being treated differently from others who have been charged with the same crime in similar circumstances,’’ Collings wrote in the 11-page memorandum, adding that prosecutors’ rationale for the dismissal was inadequate.

Three other defendants charged with the same offense had to appear before Collings the same day as Sullivan, the judge noted. But Sullivan’s case was the only one prosecutors did not pursue, out of concern that the $125 fine carried by the relatively minor offense could derail his US immigration application.

In a strongly worded memorandum issued Thursday, US Magistrate Judge Robert B. Collings said the decision by Acting US Attorney Michael K. Loucks to dismiss a federal misdemeanor possession charge against Sullivan flouted a “cardinal principle of our legal system’’ - that all persons stand equal before the law.

Andrew M. Sullivan, the British author, editor, and political commentator, is one of the best-known figures in the new-media elite, and his blog, The Daily Dish, is among the most popular on the Web. But a federal judge says Sullivan did not deserve preferential treatment from prosecutors who dropped a marijuana possession charge after the journalist was recently caught smoking a joint on a federally owned beach on Cape Cod.

The ranger gave Sullivan a violation notice, which required him to either appear before Collings in US District Court in Hyannis on Sept. 2 or, in essence, pay a $125 fine. But on Aug. 26 one of Loucks’s prosecutors, James F. Lang, filed a two-sentence letter seeking to dismiss the ticket, saying only that “further prosecution of the violation would not be in the interests of justice.’’

Disturbed by the vague explanation, Collings held the Sept. 2 hearing and ordered the writer to appear, which he did.

When Collings asked Lang and Delahunt why Sullivan should be treated differently from other defendants charged with possessing marijuana on federal property, the lawyers explained that Sullivan was a British citizen applying for a certain immigration status and that the $125 penalty could imperil his application, according to Collings’s ruling.

Regardless of whether prosecutors dismissed the violation, Collings replied, Sullivan would still have to tell immigration authorities that he had been charged with a drug crime if asked on an application. But Lang and Delahunt said immigration lawyers had told them that it was the penalty that could hurt his prospects.

In his memorandum, Collings said he was not concerned about whether possession of small amounts of marijuana should be legal. He also acknowledged that Loucks’s office can decline to prosecute such offenses.

What vexed him, he wrote, was that Loucks’s prosecutors routinely pursue such offenders but were making an exception for Sullivan. If convictions of other people for the same offense jeopardized their immigration applications, he wrote, “then why should Mr. Sullivan, who is in the same position, not have to deal with the same consequences?’’

Two veteran criminal defense lawyers who were not involved in the case said yesterday that they were not troubled by how prosecutors handled it.

Arnold R. Rosenfeld, the former head of the state public defender agency who teaches legal ethics at the Boston University School of Law and Northeastern School of Law, said a variety of factors might have caused Loucks to drop the case against Sullivan and not those against the other three defendants, including varying criminal histories.

Jeanne M. Kempthorne, a Salem defense lawyer and former longtime federal prosecutor, said it was “perfectly legitimate’’ for prosecutors to weigh the potential impact of Sullivan’s case on his immigration status.

“Am I offended by the notion that prosecutors take into account collateral circumstances? No,’’ she said. “They should be doing that. That’s humane.’’

Collings appeared to acknowledge in the first line of his memorandum that Sullivan’s case might not strike some as a big deal, but he thought it was.

“It sometimes happens,’’ he wrote, “that small cases raise issues of fundamental importance in our system of justice; this case happens to be an example.’’

Saltzman can be reached at jsaltzman@globe.com.

© Copyright 2009 Globe Newspaper Company.