Sgt Bill Forth was confronted by Paul Weddle, 25, and his friend Phillip English, then aged 15, after he and a colleague were called to an outbreak of trouble on a Tyneside council estate.
Mr Weddle, of Beacon Lough, Felling, and Phillip English, of Sunniside, both Tyne and Wear, deny murdering the officer in the late-night incident on 20 March last year.
John Milford QC, for the prosecution, told Teesside Crown Court that Sgt Forth, 34, and Constable Bill Hay went to Sunniside after Mr Weddle smashed a house window at Clover Hill.
After the officers split up, Sgt Forth, a father of two, was confronted by Mr Weddle and Phillip English, who began beating him with lengths of fencing, the teenager raining double-handed blows on him from behind. During the attack, Mr Weddle was heard to shout 'kill him, kill him', Mr Milford added.
Phillip English ran off and was arrested after PC Hay raced to help Sgt Forth, having heard his radio call for help.
Mr Milford said that at all times Sgt Forth 'was just doing his job and doing it, indeed, with restraint and good humour'.
In contrast, Mr Weddle - who was 'perhaps immature for his age', and Phillip English, who seemed 'mature and old for his age' - were looking to make trouble.
'They attacked him with sticks, beating him, and Weddle stabbed him to death with a sheath knife.' The sergeant was so overwhelmed that 'he didn't even have time to draw his truncheon'.
The court was told that Mr Weddle struggled on with Sgt Forth and a watching woman described how he made 'stabbing moves'. Mr Weddle ran off after a man armed with a rolling pin went to help the officer. A nurse also went to Sgt Forth's aid but he died before ambulance men could arrive.
The court was told that on the night that Sgt Forth died, Mr Weddle and Phillip English were among a group of young people who had earlier gathered around a bonfire in a nearby woodland clearing drinking alcohol, taking drugs and sniffing lighter fuel.
Mr Weddle, described as in a 'wrecked' state, went to the home of Nicola Robinson, then 15, and smashed a window after becoming upset because she had spurned him after a brief relationship.
She had transferred her affections to another member of the group, Gary Gray - and it was this which sparked off the leading to Sgt Forth's murder, the court was told.
Sgt Forth's widow, Gill, sitting in the public gallery, fought back tears as the prosecution outlined details of her husband's death.
The case continues today.