Three Boston police officers were shot and a suspect shot and killed Tuesday during a standoff in the city’s Dorchester neighborhood, police said.

The standoff began with the suspect barricaded in a home and had gone on for more than five hours when gunfire erupted in the afternoon.

The suspect died, acting Police Commissioner Gregory Long said during a press conference. The three officers suffered non-life-threatening injuries and were transported to a hospital.

Long said officers first responded to the apartment building at about 9:30 a.m. for a report of a person with a gun. Police were told an individual had threatened people inside the building with a firearm.

Officers tried to talk with the individual who barricaded himself, according to Long. Negotiations went on for about five to six hours with the suspect to try to get him to surrender.

“The individual fired at the officers, striking three officers on scene as a result of being fired upon,” Long said. “Officers on scene returned fire, striking the suspect.”

He said the individual was pronounced dead at the scene, having suffered several gunshot wounds.

Police have not identified the individual.

Mayor-elect Michelle Wu said she was briefed on the situation.

“My prayers tonight are with the injured officers, their loved ones, and those in our community who have repeatedly had to face violence and trauma in our neighborhoods in the past week,” Wu said in a statement.

The Boston Police Patrolmen’s Association, the union representing patrol officers, asked the public to pray for the officers.

“The violence against police officers must stop," the union tweeted.

The standoff comes just days after police in Boston say an officer shot and killed a man after he allegedly stabbed another police officer in the neck on Saturday.