A photograph on a squaddie's mobile phone landed him behind bars on sex charges.
The nude picture of a girl was taken in the young gunner's barracks room.
Teesside Crown Court was told Terry Ballentine, 18, handed the mobile to an Army guard when police found him sitting on his bed with a 12-year-old girl.
The guard's curiosity led him to flick through photographs stored on the phone and he found an indecent photograph of a girl, said Peter Johnson, prosecuting.
Ballentine said that he took the snap of the girl without her knowledge but had shown it to her, and admitted he was going to show it to his friends.
The court heard Ballentine had taken the girl and her friend for a drive with an Army colleague before he took her back to his North Yorkshire barracks.
Her mother contacted police when she failed to return home and the friend gave officers Ballentine's mobile number.
They called it at 3.30am and he confirmed she was with him.
The court heard he was already wanted for taking a car without consent, but when an officer told him he was under arrest, Ballentine finished the sentence for him, saying: "For underage sex."
He said the girl had told him she was 15, but her friend insisted she told him the girl was only 12.
Rod Hunt, defending, said: "This young girl was, according to the doctor, sexually mature and there was clearly consent in layman's terms, even though legally there was no consent."
Ballentine, of Arbroath, Scotland, is with the Royal Artillery at Allanbrooke Barracks, Topcliffe, North Yorkshire. He was remanded on bail for four weeks for reports after he pleaded guilty to unlawful sexual intercourse and making an indecent photograph on March 13.
Comments: Our rules
We want our comments to be a lively and valuable part of our community - a place where readers can debate and engage with the most important local issues. The ability to comment on our stories is a privilege, not a right, however, and that privilege may be withdrawn if it is abused or misused.
Please report any comments that break our rules.
Read the rules hereComments are closed on this article