A "dangerous" and delusional stalker has to be freed because there isn't a bed in a psychiatric hospital for him.

Alan James Fagan, 48, is currently serving the maximum prison sentence possible for his offence of stalking a solicitor.

But when the Recorder of York Judge Sean Morris with two magistrates wanted him to be detained in a psychiatric unit for a detailed psychiatric assessment, they were told that would not be possible for several months.

Fagan is halfway through his six-month sentence, the point at which prisoners are generally released.

District judge Adrian Lower declared him to be a "dangerous" and "obsessive" man when he passed the sentence at York Magistrates Court.

He had heard from the solicitor and other witnesses how Fagan didn't know her, but had pestered her persistently for several months by email and social media and had written her a letter which she found so disturbing she feared he may harm her.

Fagan found out her home address which is many miles from York, and was preparing to go there with gifts when police arrested him.

He appealed his sentence and conviction to the York Crown Court.

The judge and magistrates dismissed his conviction appeal and were considering confining him under the Mental Health Act instead of the prison sentence.

They received reports from two psychiatrists declaring that he was delusional and recommending he be sent to a secure psychiatric unit for a more detailed assessment.

But the judge and magistrates were told there was no bed available at a low secure unit for him, and one would not be available for several months.

"It is with great regret, and it is down to resources, but we are going to have to abandon that avenue," said the judge at York Crown Court sitting at Leeds.

He and the two magistrates said the six-month sentence passed on January 31 would stand.

Because Fagan, of Bishopgate Street, York, was charged with simple harassment, the maximum sentence he could receive was six months. He had denied the charge.

He remains subject to a restraining order which bans him indefinitely from contacting the solicitor in any way, going to any street where she is living or he believes her to be living, and from contacting any solicitors' office where she may be working, including her current firm.

Like everyone else, he is subject to the lockdown restrictions to stay at home and not to travel outside his local area.

The judge ordered that the police warn the solicitor of Fagan's imminent release, halfway through his sentence.

.