Thomas Fallon admitted child abduction and was told by Judge Jeremy Richardson QC that he had been "very foolish".
-> Mum killed by speeding drunk driver who took cocaine before getting behind wheelBut the judge told Sheffield Crown Court: "According to her, he behaved entirely properly towards her in a way that's, perhaps, unusual in this day and age.
"It's most unfortunate that it's actually a crime but it's an unhappy situation, for everybody concerned."
Fallon was jailed for three months by Judge Richardson on Thursday, but released immediately due to the amount of time he had spent on remand.
Judge Richardson told him: "You must be punished but I must keep a sense of proportion."
He said: "You have been more than adequately punished over the last few weeks."
Neil Coxon, prosecuting, described how the 15-year-old girl, who is from the Doncaster area of South Yorkshire, met Fallon and they started what she told police was "a sort of relationship" which involved some kissing and cuddling but no sexual activity.
Mr Coxon said she was having some issues in the area where lived, which the judge summarised as being "fed up with her situation".
He said she left home on September 22 and travelled by train and taxi to Harrogate, where she met Fallon.
The pair then travelled to Edinburgh where they stayed until a cafe owner called the police on September 30.
Mr Coxon said the pair stayed with friends of Fallon in Edinburgh - with the girl taking a bed and the defendant sleeping on the sofa - but also camped for some of the nights.
The judge was told that the girl's mother had outlined her deep concerns in a victim personal statement which was not read out in court.
Judge Richardson said he understood that the mother was "understandably very troubled by what has happened", but hoped his comments in court would help her understand what happened.
He said Fallon and the girl appeared to have "run off together" and she had a "level of infatuation" with the defendant.
The judge said to the defendant: "This girl went entirely voluntarily. There was no coercion on your part. Furthermore, there was no sexual impropriety. It was, however, very foolish."
He said there was evidence that Fallon had encouraged the girl to return home during the "excursion to Scotland" but she did not want to go back.
He said: "You have committed a crime but it's important, however, that I look at this case realistically."
Fallon, of Mayfield Grove, Harrogate, has previous convictions for theft and drugs offences, the court heard.
As he left the dock, he said to the judge: "I think you've been fair, thank you".