He had been called over allegations the man had stabbed three people with a large combat knife at late night prayers.

One of his colleagues fired a Taser at the man but it had no effect.

A worshipper, who did not want to be named, said: “I heard shouting behind me as I was praying.

“I turned around and saw two men grappling each other. Suddenly a man pulled out a knife and stabbed the other man in the leg.

“Someone tried to intervene but the man just went for him and thrust a knife into his abdomen. It was absolutely terrifying. I was shaken and panicked.

“When the police arrived they tried to Taser the man but he didn’t fall down. Instead he just lunged at the officer after pulling out his knife again and stabbed him.

“There was blood everywhere. It was devastating.”

Another eyewitness said: “It turned violent quite quickly. Some people tried to get the man to calm down and asked him to leave. It was extremely scary. This is a place of worship – not a battlefield.”

Violence erupted shortly after 11pm on Saturday during last prayers at Madrassa Qasim Ul Uloom mosque in Birmingham.

An off-duty surgeon worshipping in the mosque at the time of the attack helped to treat those hurt.

The injured officer, from the Yardley Wood area, needed surgery for non life-threatening injuries and was recovering in hospital last night with his family at his bedside.

Police said a man aged 28 was stabbed in the arm and a 36-year-old man was stabbed in the thigh. Both were in hospital last night. A third man who suffered a hand injury was discharged yesterday.

The suspect, a 32-year-old male of Somali origin, was deemed unfit to be interviewed and taken to a secure mental health facility.

Chief Supt Alex Murray, of West Midlands Police, said officers do not believe there are links between the attack and the horrific murder of soldier Lee Rigby in London. He said: “There’s no connection with any other incidents that we can see at the moment. But we’re exploring what motivated this individual.”

Mohammed Shafiq, leader of Muslim organisation the Ramadhan Foundation, said he feared extremists would try to take advantage of the incident. He added: “Our immediate thoughts are with the victims injured and their families.”