Ibn Abi al-Zinad (may Allah have mercy on him) narrates from his father (may Allah have mercy on him), who reports from the jurists of the people of Madinah whose opinion is final, that they used to say: Wagering on a horse race is permissible when a third horse is brought in. If it wins, it takes the stake money; and if it loses, no penalty is imposed on it. And this third horse should be similar to the (other) horses in speed and quality.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب السبق والرمي / 19773