James Hateley, 30, met up with the youngster in Edinburgh city centre before taking her to the popular takeaway outlet, where the pair were seen kissing while sitting in a booth.
Hateley then took the 13-year-old victim into the disabled toilet, where he kissed her, removed her clothing and touched her on the body.
Hateley, from Tranent, then sat down on the toilet seat with the child facing him and had sex with her during the incident in May 2022.
The 13-year-old victim returned to her home and later confessed to police what had happened to her in the toilet.
Hateley was arrested and charged, and appeared from custody at the Capital court last Tuesday, where he pleaded guilty to having sex with the underage victim on May 29, 2022.
He also admitted to an offence of failing to appear at a court hearing on March 12 last year.
Sheriff Julius Komorowski placed Hateley on the sex offenders’ register on an interim basis, remanded him in custody and deferred sentence to later this month.
The sheriff also forwarded Hateley’s name to Scottish Ministers for consideration of being added to the list of those banned from working with children and vulnerable adults in the future.
Fiscal depute Chelsea Martin told the court that the child was living in supported residential accommodation and left without permission from staff, leading to the police being alerted at about 6pm on May 28, 2022.
She made her way to the Capital’s Princes Street, where she met up with Hateley and the pair “spent the rest of the evening and early morning walking around” the city centre.
The court heard that Hateley had attempted to get the a hotel room but was unsuccessful and the pair later ended up at the McDonald’s restaurant on London Road at about 6.30am the following morning.
Ms Martin said: “While in the locus, a McDonald’s restaurant, they were cuddled up together within a booth, holding hands and kissing each other on the lips.
“The complainer then checked there was an available disabled toilet within the restaurant. The pair then entered the toilet, where the accused locked the door.
“They began kissing and the complainer removed her joggers. The accused removed the complainer’s pants and [performed a sex act on her].”
The court was told that Hateley sat on the toilet with the girl facing him and they had sexual intercourse.
The child went to the ladies’ toilet and Hateley then left the area shortly afterwards.
The fiscal depute said that the police eventually traced the young girl and, during an interview, “she disclosed what had happened” to her at the McDonald’s toilet.