It was narrated from Abu Hurairah that the Messenger of Allah (ﷺ) said:
“Whoever enters a horse (in a race) between two other horses, not knowing whether it will win, that is not gambling. But whoever enters a horse (in race) between two other horses, certain that it will win, that is gambling.”