The really big bets happen at bigger tracks, particularly at the 10-000 capacity Gonbad-e Kavoos hippodrome in northern Iran.
Cleric Mahmoudi warned of the dangers of gambling.
"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.
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.
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. Odds are not given before the race and returns are calculated afterwards.
"Last year someone won $75,000 there in a bet," a race official said, speaking on condition of anonymity.
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".
(Editing by Sonya Hepinstall)
However, three forms of gambling are permitted under Islam, said a cleric consulted on the matter by Reuters.
"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".
"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.
After the revolution the idea fell out of favour and today there are only four racetracks in the country. I predicted correctly," said the 18-year-old.
THE BIG BETS
"I just paid 50,000 rials. "Big bets take place unofficially and the winnings are exchanged from hand-to-hand."
"I knew he would win. Not by "betting" on the horse, he insisted -- betting is illegal under Iran's Islamic law -- but by "predicting" Rio Collection would win.
"People are reluctant to place big bets with the prediction office," he said . "In a way we are donating this money to help develop the races."
Betting among individuals is not legal but still goes on.
People can also place bets on horses through the federation's website, but that misses out on the spectacle.
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.
Inside, a dozen women, wearing obligatory headscarves, sit behind windows, taking predictions and paying out winnings. It hold races over a 10-week season each year.
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.
He had just won 200,000 rials (almost $20). 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 way it works is that jockeys authorise the horse-racing committee to place bets for other people on their behalf.
"I had a great time," Tamanna said. As well as a computer screen with race details, each has a basket into which they toss the takings.
. I hope I can win something," said Erfan, 15.
"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.
Prediction tickets can be bought for as little as 10,000 rials (around $1) with no official upper limit, although large bets are rare. 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.
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.
NOWRUZABAD, Iran As Rio Collection galloped across the finishing line, Sardar hooted with joy and high-fived his friends.
In pre-revolutionary Iran, horse riding was considered an elite sport. By Mitra Amiri
| NOWRUZABAD, Iran
Most of the people buying prediction tickets legally from the racetrack office did not seem concerned, however.
Under Islamic sharia law, gambling is generally seen as illegal and Sardar's wager, made with a friend, was actually not permitted. 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.
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.
"I always buy prediction tickets from this office but my dad bets directly with others," he said