The man accused of shooting trainee Pc Rachael Bown has admitted firing the shots but denies aiming a gun at her.
Rachael Bown was shot in the stomach
Trevon Thomas, 24, of Bilborough, told a jury at Nottingham Crown Court that the gun went off accidentally as he ran away from police.
Mr Thomas, who denies attempted murder, apologised for injuring Pc Bown.
He told the court: "I'm very sorry about Miss Bown's injuries, but it was an accident. I was under the effects of the CS gas."
The 24-year-old probationary Pc was shot in the stomach while on patrol in the Lenton area of Nottingham on 14 February 2006.
She suffered life-threatening injuries when she was shot below her body armour, while investigating reports of a burglary.
The prosecution claims Mr Thomas shot Miss Bown deliberately.
But in testimony on Friday, Mr Thomas said he was blinded by CS spray fired at him by another police officer and the gun went off three times accidentally as he wiped his eyes.
He told the court he was not aiming at her.
Mr Thomas, who came to the UK from Trinidad in 2000, told the jury he was carrying the Browning 9mm pistol, loaded with 13 rounds of ammunition, for "protection".
He said he had previously witnessed a friend shot dead in the city and had been injured by a firearm himself a few years previously.
The jury heard he bought the pistol in 2002 and kept it locked in a shed at his home in Melford Road, Bilborough.
He took it out that night because he had heard a man, who cannot be named for legal reasons, was looking for him and was likely to be armed with a weapon.
The gun was stashed in the waistband of his trousers, cocked, but with the safety catch on, he added.
The jury heard that Mr Thomas ran when the police began to question him because he was scared he would be caught in possession of a firearm.
As he approached Pc Bown and her colleague Martin Foster, Mr Thomas claimed the safety catch "accidentally" came off the gun and he inadvertently pulled the trigger.
Mr Thomas also told the court he did not realise the first bang he heard from the gun, moments after Pc Foster fired CS spray at him, was from his weapon.
"I was running away from the policeman and she accidentally got shot. I don't know when she got shot or how she got shot," he said.
Mr Thomas said he fled Nottingham and attempted to return to Trinidad because he did not want to accept responsibility for what he had done.
"I was very frightened and very afraid and very panicky," he said.
The trial continues.