Denver Harris, aged 37, had been harassing his ex-partner for months and when by chance they bumped into each other on Hurstwood Road in Kingstanding on April 2 this year, he became abusive.
He took a gun out of his waistband and fired two rounds in the air to frighten her.
The next evening, two local policing officers were patrolling the Kingstanding area following a spate of bike thefts, when they noticed Harris acting suspiciously.
They went to stop him, but he ran towards an alleyway on Twickenham Road. He pulled out a gun and shot towards one of the officers who had taken chase, before running away.
Police recovered bullet casing from the scene, which forensic experts later confirmed had come from a blank firearm.
A man hunt began and Harris was arrested by firearms officers on April 4 after he tried to escape over garden fences on College Road.
Harris, who is from Parkeston Crescent, Birmingham, pleaded guilty to possession of an imitation firearm with intent to cause fear against the police officer and his ex-partner, and also harassment against his ex-partner.
He was jailed for six years and two months at Birmingham Crown Court on Tuesday.
PC Stefan Lungu, from the Major Crime Team, said: “Harris is a dangerous and abusive individual, who had been harassing his ex-partner for some time. We believe that he carried an imitation firearm to provoke fear.
“The officer’s initial belief was that a blank firer had been used, as he wasn’t injured. However, he then faced the realisation that the firearm could have been live and viable; the weapon may have misfired or jammed or the suspect may have just missed his target.
“The long-term impact of this crime on the officers and their private lives is yet to be determined. It is undeniable, however, that despite the danger officers face during their daily duties, being confronted and shot at with a firearm, live or not, should not be one of them.”