U.S. lawmakers on Friday were close to finalizing a historic overhaul of financial regulations as they reached a preliminary deal on derivatives, the most contentious sticking point of the bill.

As a marathon negotiating session hit the 18-hour mark, a lawmaker involved in the discussions told Reuters that Democrats had agreed to a compromise that will allow banks to retain the bulk of their lucrative swaps-dealing operations.

If lawmakers agree to the deal, that would resolve the final hurdle in the most sweeping rewrite of the Wall Street rulebook since the 1930s. The bill would boost consumer protection, tighten financial regulations and reduce the industry's profits by billions of dollars.

In a wood-paneled room on Capitol Hill, financial regulators and Obama administration officials huddled with tired lawmakers who chomped on chocolate bars to stay sharp as they weighed billion-dollar decisions.

I've been here long enough, said Democratic Representative Collin Peterson, who offered the derivatives compromise. We need to get this done.

Democrats face enormous pressure to complete work on the bill in the coming hours, before Obama discusses recovery and reform with leaders of other economic powers at the Group of 20 meeting in Canada.

Lawmakers have already resolved the other major sticking point in the bill. Around midnight, they approved a modified version of the so-called Volcker rule, which would curb risky trading and some investment activity by banks.

It would give regulators little wiggle room to waive the trading ban but would also allow banks to invest up to 3 percent of their tangible equity in hedge funds and private equity funds.

On Wall Street, the prospect of tough new rules sent U.S. bank stocks lower on Thursday, helping to pull down the overall market. The KBW banks index closed down 2.2 percent.

Both the Volcker rule and the swaps-dealing proposal would shield banks' taxpayer-backed assets from the risky trading activity that led to the 2007-2009 financial crisis and massive taxpayer bailouts of Wall Street.

The reform bill -- nearly 2,000 pages in all -- aims to avoid a repeat of the crisis that plunged the global economy into a deep recession and led to taxpayer bailouts of troubled banks.

The crackdown aims to tame the $615 trillion derivatives market by forcing much trading activity onto exchanges and clearinghouses. Over-the-counter derivatives worsened the financial crisis and led to a $182 billion taxpayer bailout of insurance giant AIG.

Democratic Senator Blanche Lincoln would force banks to spin off their lucrative swaps-dealing operations into separately capitalized affiliates. Dozens of Democrats in the House of Representatives say that could force derivatives trading offshore and have threatened to vote against the bill if it includes the provision.

Obama administration officials huddled with lawmakers for hours to work out a compromise.

The compromise would allow banks to stay involved in foreign-exchange and interest-rate swaps dealing, which account for the bulk of the $615 over-the-counter market. House Democrats accepted it after hours of objections, according to a lawmaker involved in the talks.

BLUEPRINT FOR OTHER COUNTRIES

Passage of the bill would give Democrats an important legislative victory, alongside healthcare reform, ahead of congressional elections in November.

It would also give Obama a blueprint for other countries at the G20 meeting as they strive to coordinate their reform efforts.

As the global economy emerges from the financial crisis of 2007-2009, Europe's efforts to present a united front on regulation hit a roadblock on Thursday when lawmakers and diplomats failed to agree on new hedge fund rules.

Wall Street lobbyists have been unable to kill the overhaul as Democrats ride a wave of public disgust at bank bailouts and bonuses. But Democrats have to balance their desire to crack down on Wall Street with the need to retain the votes of moderates from both parties.

Democrats hope Obama can sign the reforms into law by July 4 but the final package must first win approval in the House and Senate.

One Senate moderate, Republican Scott Brown, was at the center of efforts to carve out exemptions to the Volcker rule, for mutual funds, insurers and banks in his home state of Massachusetts.

Large financial firms might have to pay a tax of roughly $19 billion, spread out over several years, to cover the cost of the bill, said Democratic Representative Barney Frank, who is chairing the panel.

Lawmakers resolved some other sticking points.

The panel agreed to tighten bank capital rules to help them ride out future crises.

Banks would have five years to meet the rules, which force them to exclude some riskier securities from core capital. Banks with less than $15 billion in assets would be exempt.

Some $118 billion in bank assets would not count toward the new capital requirements, according to credit ratings agency Moody's Investors Service.

On other issues, the panel agreed to let regulators set higher standards of duty for broker-dealers who give financial advice and agreed to give investors an easier way to nominate corporate board directors.

They also watered down a provision to give shareholders a nonbinding vote on executive pay. That vote would take place once every two or three years, not annually.

(Additional reporting by Kim Dixon, Roberta Rampton, Kevin Rachelle Younglai and Andy Sullivan; writing by Andy Sullivan; Editing by Alistair Bell, Jackie Frank and Anthony Boadle)