A Vallejo police officer on Thursday shot and killed an attacking pit bull that had been intentionally been let loose by a fleeing suspect, authorities said.

The incident began about 10:45 a.m. when two officers tried to stop Matthew Vallejos for trespassing on state-owned property that was fenced off, said Vallejo police Lt. Sid DeJesus.

Vallejos fled on foot and ran toward a homeless encampment in an area of thick brush, DeJesus said. As the officers tried to arrest him, a pit bull emerged from the encampment and attacked one of the officers, police said.

The pit bull bit down on the officer and then “began to violently pull the officer around the property,” DeJesus said.

The officer managed to kick the dog to gain some distance, but the animal “stood its ground and continued to aggressively run toward the officer to initiate another attack,” DeJesus said.

The officer, afraid he was going to get bitten again, fired a gunshot at the dog, killing it, police said.

“In the bushes, the homeless encampment between Lewis Brown and (Highway) 37, I had to shoot a dog!” the officer reported on the police radio as the sounds of a dog whining could be heard in the background.

Police later determined that Vallejos had cut a line connecting the dog, which belonged to someone else, to a tent, DeJesus said. The dog’s owner confirmed to police that the animal “was familiar with suspect Vallejos and that he knew the dog would attack the uniformed police officers, which is why suspect Vallejos cut his line.”

The injured officer suffered a moderate wound to his right leg and was treated at a hospital and released. The second officer suffered minor cuts and scrapes from being dragged into the brush by the suspect, DeJesus said.

Vallejos was booked at Solano County Jail on suspicion of trespassing, obstructing an officer, animal cruelty and a probation violation.

Henry K. Lee is a San Francisco Chronicle staff writer. E-mail: hlee@sfchronicle.com Twitter: @henryklee