A man accused of stabbing an off-duty police officer 11 times after becoming "fixated" with him has admitted attempted murder.
John McCartney, 40, launched the frenzied attack when the victim answered his door in Rayleigh, Essex, on April 24 last year while his wife and children were at home.
McCartney, who is currently being held in a secure psychiatric facility, admitted attempted murder and possession of an offensive weapon at Basildon Crown Court via video-link on Monday morning.
McCartney spoke only to confirm his name, date of birth and give his nationality as British, and to enter his guilty pleas.
Judge Samantha Leigh adjourned sentencing until March 6 when she will hear evidence from McCartney's psychiatrists about his mental state.
Essex Police said McCartney and the officer had been at school together and the defendant had become obsessed with the victim despite the pair only ever saying "Hello" in passing.
In the weeks before the attack, McCartney conducted a campaign of harassment against the victim on social media.
On the night of the incident, the officer heard a knock at the door at around 9pm.
McCartney launched a "sustained and frenzied knife attack" on the victim on his doorstep, the force said.
Essex Police said in a statement: "Despite suffering 11 stab and slash wounds, a number of which were extremely serious, our officer, using tactics learnt during his police training, battled valiantly to keep McCartney away from his family, and to restrain him to prevent him causing harm to his family and neighbours."
The officer suffered six stab wounds to the centre of his chest, lacerations to his chest, arm and abdomen - exposing his bowel - a half-inch wound to his upper arm, and wounds to his feet.
Despite the severity of his injuries, the victim managed to tackle McCartney to the ground, jump on his back and lie on him until help arrived.
The officer's wife and neighbours helped him to restrain McCartney. Essex Police said the sergeant is now recovering at home and has yet to return to duties.
The victim said in a statement: "The events of Wednesday April 24 have had a huge impact on not just my life but those of my family, close friends, neighbours and policing colleagues.
"They, like me, continue to live with the emotional scars of that day but I am thankful to all of them - my wife, family, friends, neighbours, colleagues and paramedics who undoubtedly not only saved my life that day but continue to support me since.
"Words are not enough to express how much everything they have done and all of their love and support has meant to me."
Chief Constable Ben Harrington paid tribute to the bravery of the wounded officer, saying: "I'm in no doubt that his heroism in tackling an armed man whilst critically injured protected the community, protected his family, and Essex is safer as a result."
He also praised the officer's family, adding: "I say thank you to the emergency services, to his neighbours, to the community and the doctors, medics and paramedics who undoubtedly saved his life."
The officer is still recovering, but the chief constable said he hoped "a man of his bravery" would be able to continue to serve with Essex Police. The officer received an award for "outstanding act" from the force in October last year.