Murray pointed a "sinister" ball-bearing gun at the officer, who was shocked and feared for his safety.

He warned the policeman: "If you come near me, I'll kill you."

The officer released Logan but Murray fired the gun directly at his head, with pellets hitting it.

"The dog began to shake its head frantically," said Mr Evans.

Murray fired the gun at the officer's head, hitting him above an eye.

The policeman "continued to charge towards" Murray and forced him back but Murray warned him: "I'm taking you with me."

The officer suffered multiple pellet wounds to his head and face from point-blank range and Murray pointed the gun towards PC Sweeney's knee and fired into it.

Logan and PC Sweeney

An armed response unit was called in and Murray surrendered.

He was found with knives, cartridges, pellets, a scalpel and cannabis.

PC Sweeney suffered bruising but Logan had made a good recovery, with no lasting effects.

Police had been called in because of an earlier incident in which Murray stabbed a 68-year-old man in a Grimsby doorway after accusing him of being a "nonce" and a "paedophile".

There had been sexual activity between Murray and the pensioner, who had paid him significant sums of money.

Murray had demanded £300 cash from the pensioner but it was not paid.

After the stabbing, Murray told a woman: "I have just stabbed a nonce down the street. Have a good day, love."

The victim suffered two stab wounds.

Andrew Bailey, mitigating, said that Murray acted out of character and had used only minor violence in the past.

Joshua Murray, who has been jailed for nine years for shooting a police dog and his handler and stabbing a pensioner (Image: Humberside Police)

The attack on the pensioner was premeditated and the police were only doing their job when they went to arrest Murray.

He had been suffering from problems at the time but had shown remorse. He was now free of drugs.

Judge Simon Jack said: "It must have been extremely frightening for everyone involved in it. It was a terrifying incident."

Murray was jailed for nine years and was given an indefinite restraining order concerning the pensioner.

The weapons found will be confiscated.

Following the hearing, Mr Evans said: "Murray is clearly an unpredictable and dangerous criminal who had amassed a collection of weapons and imitation firearms.

“It is only by great good fortune and due to the first victim wearing a thick overcoat at the time of the attack that this incident did not result in even more tragic consequences.

“The police dog handler received injuries to his head as well as cuts and bruises. Throughout the incident he was in fear of serious injury.

"Police Dog Logan also received gun-pellet injuries from the imitation firearm. Both thankfully have since recovered.

PC Ian Sweeney who was shot by Joshua Murray

"I hope the sentence passed today is some comfort to his victims."

Meanwhile, chairman of Humberside Police Federation, which represents police officers, Peter Musgrave, said: "It is quite a good sentence for what happened. Nine years is appropriate. The judge has clearly taken into account all the factors.

"With Ian doing his duty and the police dog, the sentence seems to reflect the gravity and it is what we would expect of the judge."

He added: "This is a relatively top-end offence in the scale of assaults on police officers. That is not to diminish the daily experience of spitting, punching and kicking of our officers.

"I hope this sends out a message. The Chief (Lee Freeman) has been very vocal in highlighting how unacceptable assaults on police officers are. We all want that message to get out and the judge has taken that on board."

From next Thursday, sentences for those who attack emergency services personnel will be tougher.

Earlier this month, Keith Hunter, Police and Crime Commissioner for Humberside Police slammed a judge who jailed thug Josse Jackson for just eight weeks for attacking two officers.

The sentencing came just hours after Chief Constable Lee Freeman demanded tougher sentences for culprits following a weekend in which 11 of his staff were assaulted.

Mr Hunter said: "Anyone who thinks this is an appropriate sentence after this person has committed the acts they have, is so far detached from the realities of what normal people face on the streets every day, and of the dangers faced by police officers and staff, that they risk undermining the confidence in the justice system to such an extent that we are building up much bigger problems for the future.

"It is often said society gets the police service it deserves. If society wants a good police service it should rise up and challenge these decisions and make its collective voice heard."

Follow the Grimsby court mouse

He's been scurrying around the courts for more years than he cares to remember but now Grimsby court mouse has gone digital. Follow the ins and outs at Grimsby's Magistrates Court and Crown Court with the rodent who knows every nook and cranny, from the dock to the cells.