(Adds comments from lawmakers, background)
By Mark Weinraub and Tom Polansek
CHICAGO, March 13 (Reuters) - U.S. lawmakers said on Tuesday they agreed to revise a portion of the new tax code that gave farmers a massive tax break for selling crops to cooperatives, in a win for private grain firms that were disadvantaged by the overhaul.
The agreement, which lawmakers have been scrambling to reach for months, aims to replicate tax benefits that were available to farmer-owned co-ops that existed before Congress passed the tax law in December 2017, according to a summary of the agreement released by Republican senators from farm states.
The controversial provision to the tax bill, known as Section 199A, gave farmers a 20 percent deduction on payments for sales of crops to farmer-owned cooperatives, but not for sales to private or investor-owned grain handlers such as global firm Archer Daniels Midland Co.
That has driven fears among U.S. ethanol producers and privately run crop handlers, such as Minnesota's Minn-Kota Ag Products, that they could be squeezed out of the competition to buy farmers' harvests.
"It's time to have a party," said Dale Beyer, chief financial officer for Minn-Kota, in reaction to the agreement.
The section was added to the tax bill amid of a flurry of last-minute negotiations and lawmakers have admitted that the changes were a mistake.
The provision was the latest challenge for merchants such as ADM and Cargill Inc. They are also facing a supply glut that is making it tough to turn a profit on their core business: buying, processing and selling corn, soybeans and wheat.
To remain competitive, companies including ethanol producer Green Plains Inc have taken steps to establish co-ops.
The new agreement now "restores balanced competition within the marketplace," according to a statement from Republican senators, including John Thune of South Dakota, John Hoeven of North Dakota and Chuck Grassley of Iowa. They said they wanted to have the measure signed into law as soon as possible.
Grain companies expect the fix will be included in a spending bill that must be passed by the end of March.
"The old Section 199 had a proven track record of letting farmers keep more of their hard-earned money," Chuck Conner, president and chief executive of the trade group National Council of Farmer Cooperatives, said in a statement. "We expect these provisions to do the same."
Reporting by Mark Weinraub and Tom Polansek in Chicago Editing by Suzannah Gonzales and Rosalba O'Brien