A schoolboy was stabbed to death by one of his friends after he got caught up in a bungled attempt to rob a drug dealer in an affluent suburb, a jury has heard.

Yousef Makki, 17, died after being stabbed in the heart by his 17-year-old friend in Hale Barns, a suburb in Trafford, Manchester crown court was told.

Makki, who came from an Anglo-Lebanese family and lived in Burnage, had won a scholarship to attend Manchester Grammar school, and had dreamed of becoming a heart surgeon.

On 2 March, the prosecution said, he was with two other teenagers when they allegedly tried to rob a dealer of £45 worth of cannabis on a farm track. But, the court heard, their attempt failed, one of the teenagers was attacked, and his bicycle was thrown over a hedge.

During an altercation after the failed robbery, Makki was stabbed by the assaulted boy in Gorse Bank Road, Hale Barns, at about 6.35pm, the court heard.

The alleged killer, Boy A, denies murder and a charge of conspiracy to robbery. He admits perverting the course of justice and possession of a flick knife. A second youth, Boy B, also aged 17 and a friend of both the victim and his alleged killer, denies conspiracy to robbery and perverting the course of justice but admits possession of a flick knife.

The jury were told that Makki suffered a fatal knife wound to the chest and collapsed against a nearby tree. He died later in an ambulance despite the efforts of a local heart surgeon to save him.

Earlier the same day, Boy B, had arranged to buy £45 worth of cannabis from the drug dealer and agreed to meet in the Hale Barns area, the court heard. At about 4pm Makki and the defendants were recorded on CCTV in Hale Barns before walking along a dirt track nearby.

Nick Johnson QC, prosecuting, said: ‘‘[The dealer] got the impression that [Boy B] was shocked that he [the dealer] had turned up with two others in the car and he also thought that all three of the lads were high on cannabis.

“[Boy B] asked for the cannabis he had ordered but said he did not have the means to pay. [The dealer] got the impression that he was about to be robbed because having refused to hand over the cannabis in absence of payment, [Boy A] began to pull at the driver’s door and ordered him out of the car. At that point, both [Boy B] and Yousef Makki rode off on their bicycles.

The court heard the two friends of the dealer got out of the car and assaulted Boy A who then fled with a cut to his left eye leaving his bike behind, which was subsequently thrown over a nearby hedge.

Shortly afterwards Makki spoke to the dealer and said the robbery was Boy B’s idea and the pair appeared to be on good terms, the court heard. Later Boy B contacted the dealer himself to apologise, the jury was told.

The court heard the killing occurred after the group went back to the scene in a bid to retrieve the bicycle.

Johnson added: ‘‘The prosecution say that having set up the robbery, [Boy B] had fled leaving [Boy A] to take a beating … That in itself would be a fairly good reason for them to fall out. [Boy A’s] expensive bike had been thrown over a hedge – again that may have been the reason or part of the reason.’’

When asked by police what happened, Boy A falsely claimed Makki had been stabbed during a robbery but he was later arrested on suspicion of murder and in a prepared statement claimed he had accidentally stabbed Makki in self-defence after Makki tried to attack him.

The hearing continues.