A former Marine whose arrest at the Empire State Building on a gun-possession charge last September prompted outrage among supporters of gun rights pleaded guilty on Tuesday to a misdemeanor weapons-possession charge.

The agreement allowed the former Marine, Ryan Jerome, a jeweler from Indiana, to avoid a possible prison sentence of three and a half years. He agreed to serve 10 days of community service near his home and to pay a $1,000 fine.

Mr. Jerome, who was arrested on a felony charge after trying to check his pistol with security guards, had resisted for months the offer he eventually accepted in a standoff with the office of the Manhattan district attorney, Cyrus R. Vance Jr.

The charge and his military background drove Mr. Jerome’s supporters to write letters and create a Facebook page, “Free Private Ryan,” that accused Mr. Vance of being overzealous in enforcing New York’s strict weapons laws.