A police officer feared for his life when a man "looking for burglars" fired a shotgun at his unmarked vehicle, a court heard.
PC Marcus Myers told Luton Crown Court the double-barrelled gun could have been just 3ft (1m) from his head when Richard Baldwin, 35, pointed it at him.
Mr Baldwin and his father Bernard Baldwin, 63, claim they were looking for men who had burgled their garage in Leighton Buzzard, Bedfordshire.
Both deny attempted murder.
Prosecutor Martin Mulgrew said: "Richard Baldwin, assisted by his father, went driving around Leighton Buzzard looking for a group of men they believed were responsible for breaking into their business premises."
He said the pair, armed with a lawfully-held shotgun and ammunition, were "seeking retribution" - but mistook PC Myers and PC Russell Mapley in their unmarked police van for burglars.
The officers had been on their way to investigate the break-in on 22 September but were told to "stand down" following reports that Richard, of Saturn Close, Leighton Buzzard, had a shotgun.
Seeing the Peugeot van containing father and son, they decided to follow at a distance, but on a roundabout ended up ahead of the Baldwins' van.
PC Myers said he saw a muzzle flash and heard a loud bang from the passenger side of the van.
He said he then drove at up to 100mph in an attempt to get away, but the van eventually drew up alongside.
A slim man, aged about 40, pointed a shotgun from the open passenger window towards the officers, he said.
The van then blocked their way, and the same man got out of the passenger seat and again aimed the gun at the officers.
"I feared for my life. I believe the intention was to cause me serious harm", said PC Myers.
"I felt the most sensible option was to try and get away."
As he put the vehicle into reverse, he was aware of two shots being fired.
Jonathan Goldberg QC, defending Richard Baldwin, said: "Richard and his father genuinely believed that they were following Irish travellers who had just burgled their garage.
"Richard fired out of this particular shotgun three times, twice in the air and once at the front tyre of the van. He wasn't intending to kill or hurt anybody."
He said Mr Baldwin "intended only to scare the occupants of the van" and that it was a "genuine case of mistaken identity".
Both men deny an alternative charge of attempting to cause grievous bodily harm with intent, possession of a firearm with intent to cause fear of violence and carrying a loaded shotgun in a public place.
Bernard Baldwin, of Dove Tree Road, Leighton Buzzard, also denies dangerous driving.
Richard Baldwin's wife Victoria, 41, denies assisting an offender.
The case continues.