After the girl revealed what happened, the teen immediately apologised and pleaded guilty.
He was originally dealt with in the Youth Court and had completed part of his sentence, but in March this year he failed to turn up for judicial monitoring while on leave.
An arrest warrant was issued, and he was arrested in April when he was remanded in custody and the case was sent to be dealt with in the adult jurisdiction, the Christchurch Court News reported.
The judge said the offender's early life was "traumatic".
"His father was jailed during his childhood, and his mother had alcohol and drug issues which led to her jailing as well."
He ended up in care and suffered abuse "in various forms".
Defence counsel Tony Greig accepted that a jail term was the only option, but pointed out that the offending had occurred two-and-a-half years ago and it would have "lost a degree of meaning" for a young offender.
Crown prosecutor Sean Mallett agreed a rehabilitative sentence would be appropriate.
Judge McMeeken reduced the youth's sentence because he had done part of the original sentence, and because of his youth, his remorse, and his guilty pleas.
The Christchurch Court News reported that Judge McMeeken jailed him for two years with leave to apply for home detention if a suitable place in a residential rehabilitation programme becomes available.