A former soldier has been spared jail for what he called the “crime of compassion” of trying to smuggle a four-year-old Afghan girl into Britain from the squalid Calais Jungle refugee camp.

Rob Lawrie, 49, of Guiseley, near Leeds, appeared close to tears as – to loud applause in the courtroom – a French judge said he would only have to pay a fine of €1,000 (£755). The fine will be waived completely if after five years he had committed no further offences.

His illegal attempt to get four-year-old Bahar Ahmadi into Britain, where she would have lived with relatives already in the country, had carried a maximum sentence of five years in jail.

Fearing what awaited him at Boulogne’s Tribunal de Grande Instance, Lawrie had not slept for four days.

A fortnight after his October arrest, facing the break-up of his marriage because of what he had done without consulting his wife, the father-of-four had attempted to take his own life.

After the presiding judge Louis Betermiez gave him only a suspended fine, Lawrie declared himself “absolutely elated”.

Rob Lawrie leaving court on Thursday (Justin Sutcliffe)

“Thank you France,” he added. “The French justice system has sent out a message today. Compassion was in the dock, and compassion won.”

Lawrie, who first revealed to The Independent in November how he sought to assist “an innocent little girl who had lost the birth lottery”, has always accepted he made a stupid mistake.

Yesterday he told the three judges: “It was completely irrational and stupid. Without the emotion attached to me at the time, I would not have done it.”

Twitching as the stress of the trial aggravated his Tourette’s syndrome and at times struggling to contain his emotions, he told a packed courtroom why, on the freezing cold night of 24 October, he finally gave in to Reza Ahmadi’s pleas to smuggle his daughter out of the camp.

“I saw his desperation for a better life for his child. The little girl fell asleep on my knee and I couldn’t leave her there. I am sorry.”

The volunteer aid worker hid Bahar in a compartment above the driver’s seat of his van. Unbeknown to him, however, two Eritrean men had also hidden themselves in the back of the van, and border control sniffer dogs detected the pair. Lawrie was arrested and had to tell police about Bahar, who was asleep in her hiding place.

At the request of the French authorities, Bahar and her father accompanied Lawrie to the tribunal.As he left court, Lawrie drew attention to their differing fates. He was returning to Leeds. Bahar was going back to the Jungle.

“How sick is that?” he said. “She is an intelligent, articulate four-year-old girl. If we get these kids into our [the UK] education system now, they will become doctors, lawyers, teachers. Or, we can leave them in the Jungle to rot and die of cold.”

Refugee crisis - in pictures Show all 27 1 /27 Refugee crisis - in pictures Refugee crisis - in pictures A child looks through the fence at the Moria detention camp for migrants and refugees at the island of Lesbos on May 24, 2016. AFP/Getty Images Refugee crisis - in pictures Ahmad Zarour, 32, from Syria, reacts after his rescue by MOAS (Migrant Offshore Aid Station) while attempting to reach the Greek island of Agathonisi, Dodecanese, southeastern Agean Sea Refugee crisis - in pictures Syrian migrants holding life vests gather onto a pebble beach in the Yesil liman district of Canakkale, northwestern Turkey, after being stopped by Turkish police in their attempt to reach the Greek island of Lesbos on 29 January 2016. Getty Images Refugee crisis - in pictures Refugees flash the 'V for victory' sign during a demonstration as they block the Greek-Macedonian border Refugee crisis - in pictures Migrants have been braving sub zero temperatures as they cross the border from Macedonia into Serbia. Refugee crisis - in pictures A sinking boat is seen behind a Turkish gendarme off the coast of Canakkale's Bademli district on January 30, 2016. At least 33 migrants drowned on January 30 when their boat sank in the Aegean Sea while trying to cross from Turkey to Greece. Getty Images Refugee crisis - in pictures A general view of a shelter for migrants inside a hangar of the former Tempelhof airport in Berlin, Germany Refugee crisis - in pictures Refugees protest behind a fence against restrictions limiting passage at the Greek-Macedonian border, near Gevgelija. Since last week, Macedonia has restricted passage to northern Europe to only Syrians, Iraqis and Afghans who are considered war refugees. All other nationalities are deemed economic migrants and told to turn back. Macedonia has finished building a fence on its frontier with Greece becoming the latest country in Europe to build a border barrier aimed at checking the flow of refugees Refugee crisis - in pictures A father and his child wait after being caught by Turkish gendarme on 27 January 2016 at Canakkale's Kucukkuyu district Refugee crisis - in pictures Migrants make hand signals as they arrive into the southern Spanish port of Malaga on 27 January, 2016 after an inflatable boat carrying 55 Africans, seven of them women and six chidren, was rescued by the Spanish coast guard off the Spanish coast. Refugee crisis - in pictures A refugee holds two children as dozens arrive on an overcrowded boat on the Greek island of Lesbos Refugee crisis - in pictures A child, covered by emergency blankets, reacts as she arrives, with other refugees and migrants, on the Greek island of Lesbos, At least five migrants including three children, died after four boats sank between Turkey and Greece, as rescue workers searched the sea for dozens more, the Greek coastguard said Refugee crisis - in pictures Migrants wait under outside the Moria registration camp on the Lesbos. Over 400,000 people have landed on Greek islands from neighbouring Turkey since the beginning of the year Refugee crisis - in pictures The bodies of Christian refugees are buried separately from Muslim refugees at the Agios Panteleimonas cemetery in Mytilene, Lesbos Refugee crisis - in pictures Macedonian police officers control a crowd of refugees as they prepare to enter a camp after crossing the Greek border into Macedonia near Gevgelija Getty Images Refugee crisis - in pictures A refugee tries to force the entry to a camp as Macedonian police officers control a crowd after crossing the Greek border into Macedonia near Gevgelija Getty Images Refugee crisis - in pictures Refugees are seen aboard a Turkish fishing boat as they arrive on the Greek island of Lesbos after crossing a part of the Aegean Sea from the Turkish coast to Lesbos Reuters Refugee crisis - in pictures An elderly woman sings a lullaby to baby on a beach after arriving with other refugees on the Greek island of Lesbos after crossing the Aegean sea from Turkey Getty Images Refugee crisis - in pictures A man collapses as refugees make land from an overloaded rubber dinghy after crossing the Aegean see from Turkey, at the island of Lesbos EPA Refugee crisis - in pictures A girl reacts as refugees arrive by boat on the Greek island of Lesbos after crossing the Aegean sea from Turkey Getty Images Refugee crisis - in pictures Refugees make a show of hands as they queue after crossing the Greek border into Macedonia near Gevgelija Getty Images Refugee crisis - in pictures People help a wheelchair user board a train with others, heading towards Serbia, at the transit camp for refugees near the southern Macedonian town of Gevgelija AP Refugee crisis - in pictures Refugees board a train, after crossing the Greek-Macedonian border, near Gevgelija. Macedonia is a key transit country in the Balkans migration route into the EU, with thousands of asylum seekers - many of them from Syria, Afghanistan, Iraq and Somalia - entering the country every day Getty Images Refugee crisis - in pictures An aerial picture shows the "New Jungle" refugee camp where some 3,500 people live while they attempt to enter Britain, near the port of Calais, northern France Getty Images Refugee crisis - in pictures A Syrian girl reacts as she helped by a volunteer upon her arrival from Turkey on the Greek island of Lesbos, after having crossed the Aegean Sea EPA Refugee crisis - in pictures Refugees arrive by boat on the Greek island of Lesbos after crossing the Aegean sea from Turkey Getty Images Refugee crisis - in pictures Beds ready for use for migrants and refugees are prepared at a processing center on January 27, 2016 in Passau, Germany. The flow of migrants arriving in Passau has dropped to between 500 and 1,000 per day, down significantly from last November, when in the same region up to 6,000 migrants were arriving daily.

On the eve of his trial, Lawrie had told The Independent of the toll the case had taken on him.

He now has just 48p to his name. In his determination to help the refugees of the Calais Jungle, he had spent his savings and sold the machines from his carpet cleaning business. He is behind with his rent and, despite an “extremely understanding” landlord, fears eviction from his home.

Calling his wife “the most beautiful human being”, he admitted she had left him. “I did all this without consultation. The last straw was my stupidity in trying to smuggle Bahar.”

He also worried about how his children would cope if he were jailed.

In early November, he admitted, he had tried to take his own life and was discovered at the last minute by a friend. “I woke up in intensive care with the most amazing pain in my torso. They told me that was from the paddles of the defibrillator the paramedics used in my front room.”

“On a selfish level, I have regrets,” he added.

“This has ruined my life.” But, his regret was offset by the fact that his case was generating worldwide attention and support.

“The global attention has been turned from young black men trying to board trucks, to the children of the refugee camps. Look at the light it has shone on the human side of the refugee crisis.”

In court his lawyer, Lucile Abassade, had argued Lawrie should be spared punishment because what he did was “an illegal act of solidarity”. French law, she said, allowed otherwise illegal acts if they were unpaid and done to protect the “physical integrity” of the immigrant.

Boulogne state prosecutor Jean-Pierre Valensi countered that there were other, legal ways to help Bahar.

Mr Valensi said that Lawrie had in fact put her in danger by putting her in a “tiny little hiding place” that was screwed shut. He was loudly booed.

Mr Betermiez listened, apparently sympathetically, as Lawrie told of growing up in a children’s home, his struggles with bipolar disorder and his suicide attempt.

He said the suspended fine was because the conditions in which Lawrie had hidden Bahar had exposed her to risk, in particular of “injury or mutilation” in the event of a traffic accident.

Leaving court, Lawrie vowed: “I will return to the Jungle, raise awareness, kick up a storm somehow.”

On behalf of Bahar, he issued a plea ”to the British people”.

“Let’s trial this, by bringing just one child into Britain. I reckon I could get enough donations to accommodate her and put her through university without it costing the taxpayer a penny.