A man fired on police for more than 30 minutes in South Carolina, using a handgun, rifle and shotgun while running from hiding spot to hiding spot before he was shot and killed by officers, authorities said Tuesday.

No officers were hurt, even though the first deputy on the scene was pinned behind his SUV, which was hit by more than a dozen gunshots, until other officers could arrive, said Berkeley County Sheriff Duane Lewis.

"He kept returning fire, moving, taking cover, shooting at the deputies. We were trying to do everything we could to end the situation peacefully," Lewis said.

The man fired dozens of shots across what turned into a sprawling crime scene along a two-lane road near Huger, a small town about 25 miles (40 kilometers) northeast of Charleston.

The shooting began around 3:30 p.m. Tuesday when a deputy tried to pull over the man after a neighbor complained he was speeding, Lewis said at a news conference.

The man jumped out of his car and started shooting at the deputy, who was trapped behind his SUV, Lewis said. The sheriff's office sent a picture on Twitter of the vehicle with a dozen bullet holes in the windshield.

While the deputy was trapped, the suspect "made statements he was going to finish him off," Lewis said.

After other officers arrived, the man started moving around and kept firing at officers, the sheriff said.

"He knew the terrain. He knew the area," said Lewis, adding the suspect had been visiting friends in the area for months.

Deputies brought in a SWAT team and hostage negotiators to try to get the man to surrender peacefully, according to the sheriff.

But as an officer approached to take him into custody, the man fired at the officer at close range, missing. Other officers fired back, killing the man, Lewis said.

The Berkeley County Coroner's Office has not released the man's name.

The State Law Enforcement Division, South Carolina's top crime-fighting agency, has taken charge of the investigation.

Television footage from the shooting scene showed dozens of police cars along a two-lane road from several agencies.