France defender Lucas Hernández will not spend time in prison for violating a restraining order after successfully winning an appeal in Spain on Wednesday.

The Bayern Munich player had his six-month prison sentence turned into a fine of 96,000 euros ($111,000), a Madrid court said. He can't commit another crime in the next four years for the ruling to remain valid.

The ruling came a day before Hernández had to voluntarily turn himself in to authorities to start serving time. He showed up in court in Madrid last week to be handed the court order to voluntarily turn himself in.

Hernández was arrested after a domestic violence incident in Spain in 2017, while he played for Atlético Madrid.

ALSO READ | Bayern coach Nagelsmann to miss German Cup game at Gladbach

He was initially sentenced to community service and then two years later was given a six-month prison sentence for violating a restraining order related to that case.

Both he and his partner had a restraining order put in place by a judge but they violated it by traveling together to the United States.

The court said it took into consideration the fact that both had agreed to see each other when the restraining order was broken, and that they have been living together and have a son without any signs of further incidents.

Hernández was a reserve in the France squad that won the Nations League this month.