A French farmer who faces up to five years in prison for helping African migrants slip into the country and find shelter told his trial Wednesday he merely wanted to relieve their suffering.

Cedric Herrou, 37, has become something of a folk hero around the French-Italian border for driving migrants across the frontier, under the noses of the French police, and then putting them up.

He is one of three people in the area to appear in court recently for illegally assisting migrants travelling up through Europe after crossing the Mediterranean in rickety boats.

Their cases have pitched the spirit of solidarity against the letter of the law at a time when border controls and migration have become hot political issues.

At his trial Wednesday in the southern city of Nice, the farmer struck an unrepentant tone.

"I'm doing it because there are people in need," he told the judge. "I'm doing it because it has to be done... Families are suffering."

Public prosecutor Jean-Michel Pretre called for Herrou to be given an eight-month suspended term, for his vehicle to be confiscated and for his driving licence to be restricted to driving only for professional use.

He accused Herrou of using the court as a "political platform" to justify his acts.

"We find ourselves in the situation of an intentional trial, the product of a media strategy designed to showcase a cause," Pretre said.

French farmer Cedric Herrou speaks to journalists outside the court of Nice, on January 4, 2017, before his trial for helping African migrants slip into France

(AFP)

"It's not the job of the judicial system to change law, and it's not its job to give lessons in diplomacy to such-and-such a country," he said.

Judgement is expected on February 10.

Herrou's olive farm sits in a valley near the frontier with Italy, near a popular route for migrants trying to skirt border controls established between the neighbours after last year's terror attacks in France.

Cutting a bohemian figure with his black beard, round glasses and flat cap, he claimed he was picking up the slack for "a state that put borders in place and is absolutely not managing the consequences."

Addressing hundreds of supporters outside the courthouse earlier, he declared: "If we have to break the law to help people, let's do it!"

He has been outspoken in his criticism of France's response to the migrant crisis, accusing the police of detaining "thousands" of minors and dumping them back across the border in Italy.

Police regularly remove migrant youths from trains crossing into France and send them back to Italy. Cars crossing the frontier are also frequently checked.

In October, Herrou led a group of activists who occupied a disused holiday village belonging to state railway company SNCF and opened it up to a group of migrants who had been staying on his farm.

Police intervened after three days to evacuate the makeshift camp, arresting the farmer.

Activist or Good Samaritan?

Protesters hold a placard reading "yes to solidarity and to welcoming migrants and refugees", as people gather outside the Nice courthouse on January 4, 2017 to support Cedric Herrou in his trial for aiding migrants to enter France

(AFP/File)

Two months earlier, he had been arrested for trying to smuggle eight Eritrean migrants by car from Italy into France.

That case was later dropped, with prosecutors acknowledging that he acted on humanitarian grounds.

But they have since taken a less indulgent view.

Herrou said he began helping migrants when he saw them "walking along the road" around 18 months ago.

At first, he would give them a lift to the local station but when immigration controls were beefed up in the region after last year's terror attacks he began taking them deeper inside French territory.

"And then a citizens' network was established," he said.

In court he admitted his actions were "political", designed to shine a light on the state's migrant policies.

"Even if you convict me, the problem will continue," he argued.

In October, a researcher at the University of Nice, Sophia Antipolis, was tried for giving a lift to three Eritrean women near Nice, shortly after their arrival from Italy.

The ruling in the researcher's case is expected Friday. Prosecutors have called for a six-month suspended sentence.

In December, a 73-year-old academic, also living in the area, was fined 1,500 euros ($1,570) for a similar gesture.