Eight law officers were shot on Monday, four fatally, as a U.S. Marshals fugitive task force tried to serve a warrant in Charlotte, N.C., the police said, in one of the deadliest days for law enforcement in recent years.

Around 1:30 p.m., members of the task force went to serve a warrant on a person for being a felon in possession of a firearm, Johnny Jennings, the chief of police of the Charlotte-Mecklenburg Police Department, said at a news conference Monday evening.

When they approached the residence, the suspect, later identified as Terry Clark Hughes Jr., fired at them, the police said. The officers returned fire and struck Mr. Hughes, 39. He was later pronounced dead in the front yard of the residence.

As the police approached the shooter, Chief Jennings told reporters, the officers were met with more gunfire from inside the home. After a long standoff, two women in the home were taken to a police station to be interviewed, the police later said in a statement.

“Today is an absolute tragic day for the city of Charlotte and for the profession of law enforcement,” Chief Jennings said. “Today, we lost some heroes that are out simply trying to keep our community safe.”

In all, four members of the task force were shot, three of whom died. The North Carolina Department of Adult Correction said in a statement that two of its veteran officers, Sam Poloche and Alden Elliott, were killed. The U.S. Marshals Service confirmed that one of its deputy marshals was among those killed. The task force is made up of officers from multiple agencies.