Bill Gates is in deep doo-doo with the tony town of Wellington, Fla., over an illegal “horse-waste storage facility” on his $8.7 million horse farm, which has been racking up daily penalties for three months in what’s become a fecal fiasco.

The Microsoft mogul purchased the sprawling property — which includes space for 20 horses, plus training grounds — in cash last year after renting posh spreads in the area for a couple of seasons. His teen daughter, Jennifer, trains at the estate and competes in horse shows nearby with fellow scions, including Georgina Bloomberg and Jessica Springsteen.

But Gates almost immediately stepped in it with the village of Wellington when he improperly installed a bin for his prolific horses’ poop too close to a local pond. “This has been going on since last year,” sniffed a source in the Palm Beach County town that holds more than 40 weeks of equestrian competitions a year, and the largest horse show in the world.

After months of warnings to move the giant manure store, Gates’ property was hit with penalties of $250 per day on two code violations dating back to July 18. That brings Gates’ bill to date to about $42,000. Then again, that’s chump change for the tycoon, worth a reported $80.4 billion this year.

Wellington’s Code Enforcement Manager, Steven Koch, confirmed to Page Six that Gates’ manure bin was in the “wrong area” — because it wasn’t at least 100 feet away from the pond. The other violation is apparently for not having a proper permit in the first place.

But Koch added that after months of letters, “We made contact with the contractor and the trustee today [Tuesday]. We don’t know what triggered it.” Either way, the receptacle is now being removed, and local inspectors will make sure it’s gone before the property works with the Wellington Department of Buildings to build a new bin.

With so many four-legged residents, Wellington takes this s - - t seriously. FAQs on the town’s Web site include “What are the requirements to build a manure bin?”

A Gates rep didn’t get back to us.