Praise be to Allah, the Lord of the Worlds; and may His blessings and peace be upon our Prophet Muhammad and upon all his Family and Companions.
Muslim jurists have agreed upon the lawfulness of giving and receiving prizes in horse or camel racing contests or in javelin throwing competition provided the prizes are given by a third party not a participant in the competition. Giving prizes willingly from a participant in the competitors is also allowed but collecting the contribution from the participants to grant the prize to a winner is not allowed. This is the opinion of the majority of Muslim scholars. The Prophet (Sallallahu Alaihi wa Sallam) said: No contest is allowed except in swordplay or horse or camel racing.
As for other competitions such as racing (elephants, mules or donkeys), swimming, wrestling, running, or weight lifting, Muslim scholars have different opinions. Some of them permitted them, while some others did not. They also disagree regarding the prizes that are granted in religious competitions such as in memorizing Qur'an, Hadith, or writing a thesis, etc.
The preponderant opinion is that the latter is allowed. Imam Ibn al-Qayyim said: Allah and His Prophet (Sallallahu Alaihi wa Sallam) permitted competition in arrow-shooting and in horse and camel racing in order to encourage Muslims to learn horse-riding and get prepared for Jihad. Based on this permission, competition and giving rewards for seeking knowledge is also permitted with a greater reason since it is the basic source to call people towards Islam and to remove the doubts that are raised against Islam.
Imam al-Mardawi wrote in Insaf: Competition in wrestling and running is a form of worship if one intends to support Islam and taking a reward or compensation for that is also permissible.
Finally, one should know that the prize or the compensation should be from one who does not participate in the competition.
As for those who try to predict a winner of any race bet on it and may win or lose their money this is forbidden since it is nothing but gambling. Allah Says (interpretation of meaning): {O you who believe! Intoxicants (all kinds of alcoholic drinks), gambling, AlAnsâb, and AlAzlâm (arrows for seeking luck or decision) are an abomination of Shaitân's (Satan) handiwork. So avoid (strictly all) that (abomination) in order that you may be successful. Shaitân (Satan) wants only to excite enmity and hatred between you with intoxicants (alcoholic drinks) and gambling, and hinder you from the remembrance of Allâh and from As-Salât (the prayer). So, will you not then abstain?}[5:90-91].
Allah knows best.