NOWRUZABAD, Iran As Rio Collection galloped across the finishing line, Sardar hooted with joy and high-fived his friends.
He had just won 200,000 rials (almost $20). Not by "betting" on the horse, he insisted -- betting is illegal under Iran's Islamic law -- but by "predicting" Rio Collection would win.
"I knew he would win. I predicted correctly," said the 18-year-old.
Under Islamic sharia law, gambling is generally seen as illegal and Sardar's wager, made with a friend, was actually not permitted. But thanks to certain religious rulings, many race-goers are permitted to put money on the horses legally as long as they are "predicting" through official channels.
The Koran describes gambling as "evil, unclean and Satanic" and people found guilty of illegal gambling in the Islamic Republic can be sentenced to flogging and jail.
However, three forms of gambling are permitted under Islam, said a cleric consulted on the matter by Reuters.
"All forms of gambling are haram (forbidden by Islam) except for horse racing, camel racing and archery," said Mohsen Mahmoudi, a cleric at a north Tehran mosque, adding that those manly, warrior sports were all encouraged by the Prophet Mohammad.
But technically, he added, only the archery contestants and riders of the horses or camels in the races are permitted to bet.
To make it possible for spectators to take part, the Equestrian Federation of Iran sought permission from senior clerics known as "sources of emulation", to whom Shi'ite Muslims turn for guidance on moral issues.
"In negotiations with some sources of emulation , we finally managed to receive permission to bet on horses under certain conditions," said Ebrahim Mohammdzadeh, an official at Tehran's horse-racing committee.
The way it works is that jockeys authorise the horse-racing committee to place bets for other people on their behalf.
In pre-revolutionary Iran, horse riding was considered an elite sport. Mohammad Reza Pahlavi -- the last shah who was overthrown in the 1979 uprising led by Ayatollah Ruhollah Khomeini -- was a keen horseman and aimed to expand racing.
After the revolution the idea fell out of favour and today there are only four racetracks in the country. Camel racing -- popular in some Arab countries across the Gulf -- is not a significant sport in Iran and archery has no great popular following.
The 2,000-capacity Nowruzabad track off a major highway to the west of Tehran is the only track easily accessible to the population of the capital. It hold races over a 10-week season each year.
Despite its limited availability, people from many walks of life crowd the "predictions" office next to the track in Nowruzabad where legal betting takes place inside a building where an electronic screen advertises: "Make a prediction, win a prize".
Inside, a dozen women, wearing obligatory headscarves, sit behind windows, taking predictions and paying out winnings. As well as a computer screen with race details, each has a basket into which they toss the takings.
Prediction tickets can be bought for as little as 10,000 rials (around $1) with no official upper limit, although large bets are rare. Odds are not given before the race and returns are calculated afterwards.
People can also place bets on horses through the federation's website, but that misses out on the spectacle.
As the horses pass the finishing line, the spectators -- including dozens of women -- jump up from their seats near the track and rush to the predictions office to see how much they have won and place money on the next one.
"I just paid 50,000 rials. I hope I can win something," said Erfan, 15.
"I always buy prediction tickets from this office but my dad bets directly with others," he said. "He once won 30 million rials."
THE BIG BETS
Betting among individuals is not legal but still goes on.
Wearing loose black trousers and speaking with a strong local accent, Sardar, a carpenter, said he chose not to buy prediction tickets as winnings were limited.
"People are reluctant to place big bets with the prediction office," he said . "Big bets take place unofficially and the winnings are exchanged from hand-to-hand."
The really big bets happen at bigger tracks, particularly at the 10-000 capacity Gonbad-e Kavoos hippodrome in northern Iran.
"Last year someone won $75,000 there in a bet," a race official said, speaking on condition of anonymity.
Cleric Mahmoudi warned of the dangers of gambling.
"The bettor makes gains easily, without working and this causes others to lose money with consequent dissatisfaction and grief," he said, pointing out one reason Islam regards gambling as "haram".
Most of the people buying prediction tickets legally from the racetrack office did not seem concerned, however.
"I just lost 30,000 rials but I had a lot of fun," said fine arts student Tamanna, 30, showing her ticket printed with a line that says cash spent buying the ticket goes to support the horse races, rather than in the hope of winning.
Of the total money coming into the official betting office, some 70 percent is given out as winnings with the remaining 30 percent going to cover the costs of racing.
"I had a great time," Tamanna said. "In a way we are donating this money to help develop the races."
(Editing by Sonya Hepinstall)