Neymar must pay 6.7 million euros ($7.53m) to Barcelona, a court ordered Friday after the player's case against his former employer was dismissed.
After his world-record transfer to Paris Saint-Germain in 2017, the Brazilian forward sued Barca for 43.6 million euros that he claimed he was due for various bonuses.
But a judge dismissed Neymar's case and instead sided with Barcelona, who had also sued their former player for breach of contract.
Neymar has five days to appeal the decision.
He joined Barca in 2013 and signed a new five-year contract in 2016, which included a renewal bonus worth 43.6 million euros, with 14 million paid up front.
Read | Neymar faces criminal complaint for homophobia
The remaining 29 million euros was due to be paid on August 1, 2017 but Neymar left Barcelona on August 3 for Paris Saint-Germain, who activated the striker's 222 million euro release clause.
Barcelona refused to pay Neymar the remainder of the bonus, insisting the terms of his contract had been broken.
The club, in turn, sued Neymar and requested the return of the 14 million euros they had paid him up front, as well as a further 8.5 million euros in damages.
"We express our satisfaction with the verdict announced today," Barcelona said in a statement.
"The ruling has fully dismissed the player's claim for payment of €43.6m and has accepted a large part of the defence presented by FC Barcelona, as a result of which the player must return €6.7m to the club.
"Since the player's representative is entitled to appeal this decision, the club shall continue to fervently defend its legitimate interests."
Despite the financial dispute between Barcelona and Neymar, both the club and the player have been eager to be reunited.
There were even discussions last year about coming to an agreement out of court but a compromise could not be reached.
Barca spent most of last year's summer transfer window negotiating a transfer with PSG but were unable to strike a deal, even as a number of different players were offered in exchange.
Read | Neymar welcome anytime at Barca, says Suarez
Neymar remains a popular figure among the leaders of the Barca squad, including Lionel Messi and Luis Suarez, with whom he formed a devastating attacking trio during his time at Camp Nou.
"I've said it many times, as a footballer Ney is one of the best in the world and I would love for him to return," Messi said in an interview with Barcelona newspaper Mundo Deportivo in February.
"He was always happy, he had fun both on and off the pitch. He brought a special sense of joy to the dressing room."
Messi added: "He is eager to return, he was always regretful. He tried a lot to come back and that would be the first step in trying to get him here."
Another attempt to re-sign Neymar was expected this summer but the financial implications of the coronavirus pandemic make an agreement even more unlikely.
"Neymar-type transfers will not happen," said La Liga president Javier Tebas earlier this month.
Neymar was brought to PSG to help them finally win the Champions League but they failed to go past the last 16 in his first two years at the club.
This season, they are one of four teams through to the quarter-finals, which will be played in Lisbon in August, according to an announcement made by UEFA on Wednesday.
Feature image courtesy: Getty / UEFA / AFP