A trial judge should not have allowed evidence of guns and drugs seized from inside an apartment building to be shown to a jury that later convicted a man of possessing a gun near that same building, a federal appeals court ruled yesterday.

The U.S. Court of Appeals for the Second Circuit reversed the conviction of Rory Jackson for being a felon in possession of a weapon outside a Queens apartment building in 2006, saying the “devastating” contraband evidence seized from an apartment “was not admitted for a proper purpose.”