By STEVEN FERRARO & LOGAN WILBER

A police detective testified on Thursday in Brooklyn Supreme Court that a gun-toting Queens man accused of killing a security guard and severely wounding another in an apparent case of mistaken identity two years ago had confessed to the crime.

In addition to his verbal confession, Det. David Centeno said on the first day of testimony that defendant Antonio Mahon, 22, wrote letters to the families of his two victims apologizing for the incident. Until being alerted to the letters sent to the families, police in Brownsville’s 73rd precinct had no suspect in the shootings.

Mahon allegedly told Centeno that he and friends were driving to his aunt’s house when he saw the two men standing outside the Riverdale Osborne Towers in Brownsville. Mahon confused them for two individuals involved in an  earlier dispute and fired shots at them. It was not until he saw news of the shooting, that Mahon realized he had targeted the wrong individuals.

Aaron Locklear was shot in the neck and the second shooting victim, James Merced was shot in the back and ended up paralyzed below the waist. Locklear was removed from life support on Dec. 4, 2014 and died shortly thereafter.Mahon allegedly confessed to the shooting and told Centeno he always carries a gun with him because “he has beef on the street,” Centeno said.

Mahon is charged with second degree murder and 17 other charges, including burglary, criminal possession of a weapon, trespassing and menacing, in connection to the shooting on Nov. 28, 2014.