Gary Dryden had initially contacted the child on Facebook in September 2016.
The 18 year-old later had sex with the youngster at a secluded area near a sports centre in Kilwinning, North Ayrshire.
The “scared” girl went on to discover she was having his baby – but went through the ordeal of an abortion after speaking with her parents.
Dryden could now face jail after he today/yesterday pled guilty to a rape charge at the High Court in Glasgow.
The teenager, of Irvine, North Ayrshire, had bail continued pending sentencing in December.
The girl had not long turned 12 when she received a friend request from Dryden on Facebook.
Prosecutor Gillian Ross said he was “unknown to her” at the time – but they exchanged messages and agreed to see each other.
It was during one meeting Dryden suggested they go to a quiet spot close to a sports centre in Kilwinning.
The court heard he told the girl he wanted to have sex with her – she initially thought he was “joking”.
However, they did although the youngster did not tell anyone what happened.
Miss Ross then explained: “A few days after the first incident, they met up.
“This pattern of contact continued and they had sexual intercourse on at least seven occasions always at the same location.”
The 12 year-old later found out she was expecting a baby.
The prosecutor told the hearing: “She was scared and initially disclosed to a friend that she was pregnant.
“Her parents became involved and, on November 28 last year, she underwent a medical termination in hospital.”
It emerged she was almost 12 weeks pregnant at the time.
DNA tests confirmed Dryden had been the father.
Police later quizzed the teenager and he admitted having sex with the schoolgirl.
He initially claimed he thought she was 17.
Miss Ross said: “He accepted that he started to think she was 14 because of ‘how young she looked’.”
The court heard Dryden had been a student at the time at James Watt College in Kilwinning. It is not know what he was studying.
Judge Lord Burns deferred sentencing for reports.