A 17-year-old boy raped and then attempted to kill the mother of his child, egged on by his new girlfriend, a court has heard.

The teenagers, from Greater Manchester, worked together on a plot that a jury heard “would be unbelievable but for the fact that it actually happened”.

The boy went to his ex-girlfriend’s house earlier this year, had sex with her against her consent and then asked her to fake her own death.

She agreed to apply makeup to her neck to appear as though she had been strangled so he could take a photo to send to someone, Manchester crown court was told. He then stabbed her in the head, face, neck and back, almost killing her.

During the attack, his new girlfriend, also 17, waited outside for more than two hours, sending him more than 50 text messages of encouragement. She asked him to video whatever was going on inside and afterwards suggested she would help him change his identity, the jury heard.

Opening the case on Monday, the prosecutor, Alaric Bassano, suggested the boy’s motivation was simply to please his new girlfriend, who was jealous after learning he had cheated on her with his 16-year-old former partner, the mother of his child.

The new girlfriend, “incensed by his infidelity”, told him “he would have to work hard to win back her affections”, Bassano said. It was a “matter of good fortune” that he did not kill his ex-girlfriend that day, the barrister said.

The boy had no grievance towards his ex and “acted not out of spite, anger, jealousy or resentment towards her”, said Bassano. “Rather, he acted simply to find favour and maintain romance with his girlfriend … [who], prosecution evidence suggests, knew what he was going to do and deliberately encouraged and assisted [him] in this violent attack.”

It was no spur of the moment assault, the jury was told. The day before the stabbing, the boy searched on the internet for “asphyxiation” and “how many years is someone in for murder”.

He turned up at his ex’s house with a large kitchen knife and brought a change of clothes. Outside, his new girlfriend was caught on CCTV texting him throughout. “Please don’t do nothing stupid with her cause if your sperm inside her and sampled, you’re going. Be careful,” she warned him in one message, asking him to record the attack: “Vid it then delete it when I see it please.”

After leaving his ex for dead, the boy sent his new partner a message saying: “I did it to prove I love you … there was no other way to keep you.” She replied, saying: “I know there wasn’t … I’m gonna protect you at all costs” – a clear acknowledgement, according to Bassano, that she was aware of “the enormity and gravity of the situation”.

She sent another message suggesting she would help him have “an entire identity change”.

Earlier in the day, she had gone to buy him Dettol wipes, which he used to clean the knife after the attack.

The boy has already pleaded guilty to stabbing his ex but insists he never intended to kill her, just cause her grievous bodily harm (GBH). He also denies rape, saying the sex was consensual.

His ex told police that she made clear she did not want to have sex with him. She said he raped her anyway and then asked her: “Would you ever let me kill you?” and “Would you ever kill yourself for me?” When she said no, he then suggested his new girlfriend had told him if he didn’t kill her, she would kill his mum and sister. Throughout, his phone kept buzzing and he showed her messages from his new girlfriend saying things such as “Hurry up, what’s taking so long?”

The boy then suggested he was only joking about killing her and asked her: “Can I just fake your death?”

She went along with this and under his instruction applied makeup to her neck to make it appear that he had strangled her. She closed her eyes and he took a photo of her. When she opened her eyes she was shocked to see he was holding a “massive kitchen meat knife”. She ordered him out of the house and he stabbed her in the garden.

Opening the case, Bassano warned the jury: “What I am about to describe sounds unbelievable – indeed it would be unbelievable but for the fact that it actually happened.”

The boy denies rape and attempted murder. His new girlfriend denies intentionally encouraging or assisting the boy to commit murder or GBH with intent. Neither can be named because they are under 18.

The case continues.