The animals, which were initially due to be sold in Turkey, left the Spanish port of Cartagena in mid-December on board the Karim Allah.
However, Turkish authorities refused to let the animals into the country over fears they had bluetongue virus, a disease that causes lameness and haemorrhaging.
The ship later returned to Cartagena on 22 February, after other countries, including Libya, had also been unwilling to accept the cargo. While tests were being conducted by the Spanish authorities, the cattle remained on the boat.
Last week, a vets’ report seen by Reuters said that many of the animals were unwell after their long journey.
Although it did not say whether the animals had bluetongue, the document suggested that euthanasia was the best course of action.
On Friday, a court in Madrid rejected an appeal against the decision to put them down. As a result, the animals will be taken off the boat on Saturday and slaughtered.
Of the 895 calves that initially left Spain, 22 of them died at sea and were thrown overboard, according to the boat’s captain Nabil Mohamad.
Speaking about the cattle’s plight, Mr Mohamad told the Spanish newspaper El Pais: “I can’t explain it. I’ve been in this for 25 years and nothing like this has ever happened to me. I don’t understand anything, it has been very hard.”
Miquel Masramon, a lawyer representing the shipowner, Talia Shipping Line, said last month that more than €1m (£866,000) had been spent on looking after the animals at sea.
However, animal rights groups have questioned how well the cattle had been cared for, with Silvia Barquero, the director of the Igualdad Animal NGO, describing their crossing as “hellish”.
“What has happened to the waste produced by all these animals for two months?” she asked last month. “We are sure they are in unacceptable sanitary conditions.”