A Texas deputy shot and killed a carjacking suspect who was reportedly beating a K-9 officer with a pistol after a foot chase Monday.

The dead man, who was not identified, was allegedly one of several males reported to have attacked and shot at a man before stealing his vehicle around 11 p.m. in Harris County, according to KPRC-TV, citing the sheriff’s office. The man whose car was stolen wasn’t seriously injured, officials said.

ALABAMA POLICE NARCOTICS DOG DIES AFTER FALLING ILL DURING PRISON DRUG SEARCH

A deputy, who was in the area with a K-9, spotted a vehicle matching the description of the stolen car just after midnight, FOX26 Houston reported, and engaged the men inside in a foot chase when the four suspected carjackers bolted from the vehicle.

The K-9 was the first to catch up to one of the men, who began to hit the dog with a pistol. The deputy ordered the man to stop but he continued beating the animal, police said.

“[He] began striking the K-9 with a pistol, brandishing the weapon at that point," Harris County Sheriff Ed Gonzalez told KPRC-TV. "We don’t know if there was gunfire exchanged, but our deputy did fire at least a shot striking the individual and he was pronounced deceased.”

Police believed the suspect was in his late teens or early 20s, the station reported.

CLICK HERE FOR THE FOX NEWS APP

The sheriff’s office said they recovered a pistol at the scene and were also able to detain a second man. Two others remain at large.

The K-9 officer wasn’t injured in the encounter.