Defending, Jameela Jamroz said father-of-one Skupian harboured ambitions of running the race and had started training for it.
She said: "He wanted to be there, he was excited. He wanted to see the runners. He says by chance he saw a race identifier on the floor.
"In his excitement he picked up the identifier thinking this was his opportunity to compete in the marathon and that this was in fact a dream come true for him.
"He joined in the marathon and completed the latter part of the race. At the time he hadn't fully quite appreciated that he was doing anything wrong.
"He dedicated the completion of it to his 7-year-old son and to homeless people to inspire them that good things can happen to those that are less fortunate."
London Marathon chief executive Nick Bitel said the episode could be seen to damage the reputation and integrity of the race, regarded as one of the best organised in the world, the court heard.
Skupian has lived in the UK for around 11 years and suffered a neck injury in a serious car crash at the end of last year, forcing him to take sick leave from a catering trade job, Jamroz said.
Around the same time he separated from his wife and become homeless.
Shortly before the race Skupian suffered a short, temporary breakdown in his mental state, she added.
He was arrested after police searched the multi-faith prayer room at Heathrow Airport, where he was found with items including a primary school worker's ID card and a pink diary holding overtime hours worked by airline staff.
Skupian viewed the airport as a temporary home and would pick up left-behind objects to pass to lost property, claiming he was going to return the items, the court heard.
Skupian, who wore a grey jumper and used a Polish translator, pleaded guilty at the earliest opportunity last month to fraud by false representation and to three unrelated counts of theft.
"The offences are so serious as only a prison sentence will suffice," magistrate Michael O'Gorman said.
Skupian was sentenced to 13 weeks for the fraud and three weeks for the theft offences, to be served consecutively.
He was also given a criminal behaviour order banning him from Heathrow Airport for three years unless he had a pre-booked flight ticket for that day.