Bayern Munich and France defender Lucas Hernandez has avoided jail time for disobeying a restraining order in 2017 after a Madrid court accepted his appeal.

The 25-year-old appeared in court last week and was given until October 28 to voluntarily enter a prison of his choosing, where he faced a six-month sentence.

However, the latest appeal Hernandez lodged was upheld by the Madrid Provincial High Court on Wednesday.

Hernandez, a World Cup winner with France in 2018, has instead been handed a suspended sentence of four years and ordered to pay a €96,000 fine.

"We consider that the appeal must be accepted and that the execution of the sentence of deprivation of liberty imposed on Lucas Francois Bernard Hernandez must be suspended," a statement from the court read.

The charge relates to a conviction of domestic violence against then girlfriend and now wife Amelia de la Osa Lorente from five and a half years ago.

He was sentenced to 31 days of community service at the time and barred from approaching or communicating with his partner for the next six months.

Four months later, Hernandez was arrested at an airport in Madrid in the company of Lorente, whom he had since married. The couple also now have a child together.

Hernandez was sentenced to six months in prison in 2019 as a result of breaching the order, with his appeal initially rejected due to being a repeat offender, but his latest appeal has been accepted.

"Regarding his family and social circumstances, it has been highlighted in the appeal that the convicted person lives with Mrs de la Osa and their son, without any new incidents between them being recorded," the court statement added.