A handcuffed prisoner repeatedly headbutted a convicted paedophile at the back of a courtroom in a stunning attack, captured on video on 30 November.

Christopher Elwell, 29, who sexually assaulted a four-year-old girl, had just been jailed for up to 15 years by a judge at Strafford County Superior Court, New Hampshire.

Court staff escorted him to a bench at the back of the room, where he sat down next to Josiah Davies, who was facing forgery charges.

Davies waited for Elwell to be seated than flew at him, landing two crunching headbutts before court staff were able to intervene and pin him down.

A representative from the local attorney's office told WMURTV the two men had no previous relationship and that the details of Elwell's offences must have set Davies off.

Elwell pleaded guilty to sexually assaulting the child, who was having a sleepover at a property he lived on and off at, in June.

He showed her pornography on his mobile phone and then reenacted some of the scenes with the girl. Another four-year-old and a nine-year-old were both present during the assault.

Elwell also pleaded guilty of failing to sign up to the sex offenders register in relation to a different offence with a 14-year-old in 2008.

court headbutt Christopher Elwell
Paedophile Christopher Elwell was headbutted by a fellow prisoner in court Police handout

The victim's mother said he still posed a danger to young girls and should be sentenced for longer than 15 years. However, the judge reluctantly offered him a plea bargain because it meant the child would not have to relive the trauma by testifying in court.

Elwell, from Somersworth, will also never be allowed to spend time with children unsupervised.

Davies' pretrial hearing was postponed as a result of the attack. He was already on probation when he was hauled in for alleged forgery and his attack on Elwell is now also being investigated.

The attorney's representative said he could be looking at up to seven years behind bars all together.