Wesley Bell, a reform-minded City Council member from Ferguson, Mo., declared victory in the Democratic primary for St. Louis County prosecutor Tuesday evening, saying he had ousted the longtime incumbent Robert P. McCulloch, who came under national scrutiny for his handling of the investigation into the 2014 shooting of a black teenager by a white police officer.

Mr. Bell led Mr. McCulloch by more than 13 points with all precincts reporting, bringing an end to Mr. McCulloch’s 27-year run as the county’s top elected prosecutor. There is no Republican candidate in the November general election, so Mr. Bell, 43, will most likely be a lock for the seat.

On Aug. 9, 2014, a white police officer named Darren Wilson shot and killed a black teenager named Michael Brown in Ferguson, igniting weeks of chaos and uprisings in the city that gripped the nation’s attention.

After a grand jury declined to bring charges against Mr. Wilson, Mr. McCulloch, 67, faced allegations that he was too close to law enforcement officials in the area to properly oversee the investigation. He has repeatedly defended his handling of the case, but in St. Louis and on social media on Tuesday, criminal justice advocates reveled in his defeat.