A gunman who wounded a police officer with a pistol was shot dead in West Yorkshire early this morning after an overnight siege.

Officers returned fire after the 42-year-old began a second round of shooting from an end of terrace house in the village of Kirkheaton, near Huddersfield, at 5.30am.

The man was named locally as Alistair Bell, described by neighbours as an unemployed loner with a history of suspected drug abuse. It is understood he was known to police and had been in prison in the past.

The building had been surrounded since shortly after 10pm last night, when officers called to question the man, who lived alone. He had allegedly made threats to the owner of a property nearby, and fetched a handgun and opened fire from his doorstep when he saw police.

West Yorkshire police said a male constable had been hit and suffered minor injuries. The man then retreated inside and fired again at intervals from a window.

Armed officers cordoned off Cockley Hill Lane, 100 yards from the centre of Kirkheaton, but did not evacuate neighbours because the position of the house was not thought likely to pose a threat.

Attempts were made overnight to negotiate a peaceful end to the standoff, but shooting broke out again this morning. The man was taken from the house by ambulance shortly before 6am but died at Huddersfield royal infirmary shortly afterwards.

A police spokesman said: "Just after 10pm yesterday, officers attended a domestic address in the Kirkheaton area of Huddersfield to arrest a man following an incident earlier in the day.

"The man produced a gun and fired at the officers. A male officer in his 20s was hit and attended hospital for minor injuries, but has since been discharged.

"We regret that the incident at the house did not conclude peacefully as we had hoped, and can confirm that the man taken to hospital from the address has now died. We are not in a position to name him at the moment."

The spokesman said shots had been "continually" fired at officers.

Margaret Ainley, who lives on Cockley Hill Lane, said: "He was a bit of a troubled lad – there were problems with drugs, I think. He never bothered me and would always wave if we crossed in the street. He didn't work, mind, and lived in the house on his own."

Another woman, who lives opposite the terrace and did not want to be named, said: "I'd gone to bed at about 9.30pm, and I was lying there when I heard what I thought were shots being fired.

"I went downstairs and I saw there were lots of police in the street. I heard one of the officers calling for back-up on the radio.

"Next minute, an officer was at the door telling us to stay inside and not to worry. We knew it was serious when the police helicopter turned up and kept on shining its beam on to the house."

A BBC cameraman at the scene said: "There were three loud bangs – possibly gunfire. Then the police started shouting, and I heard them smashing glass as they went into the house. They were shouting at the gunman to show them his hands.""

Yorkshire ambulance service said that it had deployed a hazardous area response team after the initial shootings.

One friend, who did not want to be named, said Bell was no stranger to the police and had been in prison a number of times. He said Bell had lived in Kirkheaton all his life and his parents also lived in the village.

His friend Shane Livingstone said: "He was a good bloke. A very good bloke."

Livingstone, who lives a few hundred yards from Bell's house, said they had been to school in Almondbury, Huddersfield, together.

The Independent Police Complaints Commission has started an inquiry into the incident.