Ol’ Madonna had a farm — and on this farm she had a huge tax break.

The superstar is trading in her cone bra for overalls this summer as she builds a supposed tree nursery on an old potato farm next to her Hamptons mansion.

The Material Girl purchased the taxpayer-owned parcel in Bridgehampton in a sweetheart deal — and will now collect multiple tax benefits on top of that because of her “agricultural” use of the land.

Suffolk County officials quietly approved the nursery plan late last year, and in the last few weeks the Queen of Pop’s crews have been planting Leyland Cypress, eastern white pines and Robusta juniper.

But locals gripe Madge has less interest in caring for crops than she does in creating a buffer for her new $4.9 million mansion. The nursery, like a virgin forest, would shield the eight-bedroom manse from prying eyes.

It’s “a front and a fraud,” sneered East Hampton farmer Sam Lester.

“Madonna should be ashamed for stealing from [taxpayers],” he said, and government officials should be “embarrassed” by the taxpayer money in the deal.

Suffolk County and the Town of Southampton jointly purchased the development rights to the old Grabowski family farm for $10 million in 2010 to preserve it as open land.

Madonna swooped in soon after and bought it for just $2.2 million, with the restriction that she could not build on it and must use it for the “production for commercial purposes of agricultural products,” said Suffolk County Planning Commission director Sarah Lansdale.

“Someone would have paid $17.5 [million] — substantially more than what it sold for” if development rights were intact, said Enzo Morabito, a broker with Douglas Elliman.

In addition to the discount, Madonna gets a big county tax break given to farms — paying only $2,260.28 a year in local property taxes for the 24 acres. By comparison, the owner of a single acre across the street pays $6,841.52.

And if Madonna does at least $10,000 a year in sales over two years — about 100 saplings — she can bring her tax bill down to less than $300 thanks to state agricultural breaks.

Some locals don’t think Madonna should be getting breaks meant for farmers.

“That’s not a nursery,” said Sagaponack farmer John White. “She just doesn’t want people to see her riding — and falling.”

Madonna was mum when The Post contacted her rep.