Cops collared a man they thought shot an innocent 11-year-old boy in Harlem over the weekend — but he was the wrong guy.

The man, 27, was in custody Wednesday afternoon on charges of attempted murder, felony assault and two counts of reckless endangerment — but was released hours later, according to the NYPD.

Chief of Detectives Dermot Shea tweeted about the arrest around noon, but it has since been deleted.

The boy was hit in the left leg by a stray bullet that was among a flurry of shots fired near the intersection of Madison Avenue and East 108th Street just after 3:15 p.m. Sunday.

At least 10 innocent bystanders have been shot on city streets since the beginning of June.