A senior Bradford judge has pledged to investigate after a shooting victim and the man who fired at him were held for months in the same jail against the advice of West Yorkshire Police.

The officer in the case contacted HMP Leeds saying it was “highly undesirable” that Qaiser Rafique and Hanees Shabhir had both ended up in the prison before the case was finally dealt with, Bradford Crown Court heard.

Prosecutor Stephen Wood told Judge Jonathan Durham Hall QC, who sentenced Shabhir to seven years’ imprisonment: “There is always the possibility in a closed environment that they could come into contact.”

Shabhir, 28, of Spencer Street, Great Horton, Bradford, was in Pentonville prison last October when his conviction for attempting to murder Rafique was overturned by the Court of Appeal in London.

He was then moved to HMP Leeds pending a retrial, where Rafique, 26, was serving a sentence for drug dealing offences.

Rafique, a paranoid schizophrenic, refused to get on the prison bus to give evidence at a new trial.

Shabhir’s guilty plea to the lesser offence of possession of a 9mm handgun with intent to endanger life was then accepted by the Crown and he was cleared by the judge of attempted murder.

He fired a single shot at Rafique in Summerville Road in the centre of Bradford on September 24, 2010. The bullet lodged in the door of a Lexus car and no one was injured.

Mr Wood said both men were in HMP Leeds for three months. Rafique was only moved five days before the court hearing.

Mr Wood stressed that there was no improper conduct by Shabhir.

The police wanted the matter taking up “at a higher level” because a similar situation could happen again. It was not a desirable thing for either man that they were in the same prison, although there was nothing to suggest that they ever saw one another behind bars.

Judge Durham Hall asked the Crown to write to him setting out its concerns and said he would take the matter up.

He said the court had great respect for the Prison Service, but it was “not really acceptable” that the police’s concerns were not acted upon.