Pennsylvania dropped $239 million into the saddlebags of the state's struggling horse-racing industry last year, bringing the total amount given to the moribund Sport of Kings to $2.6 billion during the last decade.

The money did not come from people betting on horses. It came from hundreds of thousands of slot-machine players who lost it — sometimes a penny at a time — at the state's 12 operating casinos.

Last year, slot machines in Pennsylvania generated more than $2.34 billion in revenue. The horse-racing industry was handed a little more than 10 percent of that for the Race Horse Development Fund. The lion's share of the slots money was used to give homeowners a slight break — usually of a few hundred dollars — on their property taxes.

But don't call the racehorse fund a taxpayer-funded subsidy, the state's horse-racing industry says.

In a July letter to state legislators, the Pennsylvania Equine Coalition called the fund an "obligation" that casino operators voluntarily agreed to pay "to offset the negative impact that the legalization of slot machines would have on live racing and the state's agricultural industry."

Created to bolster racehorse breeding in the commonwealth, the Race Horse Development Fund was begun in 2006 as part of the deal brokered by then-State Sen. Vincent Fumo (D., Phila.) to legalize casino gambling in the state.

But racehorse breeding has not flourished. Though the number of standardbred horses born in Pennsylvania has remained stable, the number of thoroughbred foals born in the state has nose-dived. Births peaked at 1,365 thoroughbred foals in 2013. The number fell to 555 in 2016, says the 2017 Racetrack Casino Benchmark Report, published Monday by the Pennsylvania Gaming Control Board.

Despite a declining number of foals, and a sharp decline in the number of spectators at the tracks over the years, the money has kept flowing.

The primary beneficiaries of those dollars: wealthy horse owners and racehorse breeders. The fund pays for 90 percent of the lucrative purses, the cash prizes awarded to race winners. It also pays for health and pension benefits for members of the horsemen's organizations, improvements to the privately owned racetracks, and covers the costs of the Pennsylvania State Racing Fund, which regulates the industry. It also pays for dozens of lobbyists to protect the horsemen's interests.

The $239 million given to the horse industry last year was larger than the entire budgets of several state departments. The Department of Agriculture operated with a budget of $143 million; the state Department of Health spent $215 million.

The horse fund has been a tempting target for legislators looking to close gaping budget holes. But even ranking Republicans have rarely been able to shake the money loose.

"It's amazing. The biggest, largest fund we have that could be redirected is the horsemen's fund," Senate Majority Leader Jake Corman (R., Centre) said in a video posted to Facebook last year. "It is amazing to me the political power they wield in the Capitol. Anytime we even bring it up it gets shot down in about half a second."

Indeed, the racing industry recently further improved its prospects.

Last year, the state passed a law expanding gaming. Within the new law was an Easter egg for the industry that further protected the money. The law now explicitly forbids the state from raiding it to spend on other programs.

The Commonwealth Foundation, a free-market think tank based in Harrisburg, has long lambasted the fund as "emblematic of corporate welfare."

"It's a tax on slot machines. It's a subsidy," said Nathan Benefield, the foundation's vice president. "And if you have money to subsidize horse racing, you shouldn't be raising taxes on working families."

Though most of the money stays in state, a large share flows to owners and businesses outside Pennsylvania's borders, concluded an independent audit in 2017. Nearly 50 percent of the race purses (about $73.6 million) go to out-of-state owners and corporations. The largest of the purses —  which can reach $1 million a race at the Pennsylvania Derby at Parx  in Bensalem — are routinely scooped up by Arab princes, Hollywood moguls, and California businesspeople.

The industry last year continued its downward slump, according to the benchmark report.

"Wagering was down everywhere in Pennsylvania," said the report's author, Kevin Kile. "The only upside was wagering from out-of-state on Pennsylvania races." Kile attributed that gain to the resumption of winter racing last year at Parx.

Attendance at the state's six racetracks saw a decline last year. The tracks had about 681,000 admissions, down 7 percent from 2016. Attendance in the 1960s hovered around 1.5 million a year.

Pete Peterson, spokesman for the Pennsylvania Equine Coalition, said there was preliminary evidence that horse racing might be on the rebound.  He said there had been an 18 percent increase in thoroughbred mares bred in 2017, while the sales price of standardbred horses rose by 25 percent. With the fund protected under the provision in the new gaming law, the horsemen are less jittery and more likely to invest to expand the sport.

"The Pennsylvania Equine Coalition is optimistic that the industry is back on the right track," he said. "These changes will help restore the industry's full economic impact on our state's agriculture industry."

This story has been updated.