Police officials said the officer opened fire because Mr. Scott, who they said was armed with a gun, “posed an imminent deadly threat.”

Although their accounts sometimes diverged, members of Mr. Scott’s family generally told local news outlets that he had not had a weapon. Instead, they said, he had been clutching a book while waiting to pick up a child after school.

The shooting revived scrutiny of a police department that drew national attention about three years ago when a white officer was quickly charged with voluntary manslaughter after he killed Jonathan Ferrell, an unarmed black man.

The shooting in Charlotte this week was the latest in a string of deaths of black people at the hands of the police that have stoked outrage around the country. It came just a few days after a white police officer in Tulsa, Okla., fatally shot Terence Crutcher, an unarmed black man, who could be seen on video raising his hands above his head. The encounters, many of them at least partly caught on video, have led to intense debate about race relations and law enforcement.

In Charlotte, dozens of chanting demonstrators, some of them holding signs, began gathering near the site of the shooting on Tuesday evening. Around 10 p.m., the Police Department said on Twitter that it had sent its civil emergency unit to the scene “to safely remove our officers.”

“Demonstrators surrounded our officers who were attempting to leave scene,” the department said. It identified the officer who fired his weapon as Brentley Vinson, an employee since July 2014. Officer Vinson is black, according to local reports.

According to the department, officers saw Mr. Scott leave a vehicle with a weapon soon after they arrived at the apartment complex.