WASHINGTON – Nearly two years after tremors on Wall Street set off a historic economic downturn, congressional leaders early Friday green-lighted a bill that leaves the financial industry largely intact but facing a more powerful network of regulators who can impose limits on risky activities.

The final bill took shape after a 20-hour, marathon negotiation between House and Senate leaders seeking to reconcile their separate versions.

The legislation puts a lot of faith in the watchful eye of regulators to prevent such a crisis from repeating. New agencies would police consumer lending, the invention of new financial products and the trading of exotic securities known as derivatives. Bank supervisors would have the power to seize large, troubled financial firms whose collapse could threaten the entire system. The bill calls for banks to hold more money in reserve to weather economic storms, but leaves the details to regulators.

But with a few exceptions, the measure avoids dictating to Wall Street what it can and cannot do. The bill does not break up big banks or ban the trading of derivatives. Nor does it significantly streamline the confusing array of financial regulators in Washington.

Both the House and Senate will vote on the legislation next week, and administration officials said President Obama could sign it into law before July 4.

The action capped a surprisingly good week for Wall Street. On Thursday, Democrats failed to pass a separate bill that would have raised taxes on some of the country’s wealthiest financiers. On Friday, stocks of financial firms jumped when trading opened in New York. Many analysts said the markets breathed a collective sigh of relief that the regulatory reform talks were over and that the results could have been much worse for the financial industry.

One firm that is likely to face more oversight is Goldman Sachs, which has become emblematic of the excesses of Wall Street. Regulators would more carefully track the firm’s riskiest activities. In the coming year, a regulatory council could force the bank to shed its sizable hedge funds and private-equity activities. It also could be banned from making financial trades for its own profit instead of for clients, shaving roughly 10 percent from the firm’s revenue. But after all of those changes, Goldman Sachs and a few other financial titans will still dominate the financial system, the analysts said.

A flurry of deal-making allowed several industries to escape the new system. At the last minute, auto dealers were granted exemptions from new consumer rules, despite their major role in lending. Most mutual fund and insurance companies avoided a ban on some risky trading. Community banks, which make up the vast majority of their industry, got a carve-out months ago.

Still, the deal reached a few minutes before dawn Friday all but ensures that Obama will see his second major legislative achievement of the year, after health care, Democrats said. It also gives the president momentum as he presses major economies in Europe and Asia to make similar changes at an economic summit in Toronto this weekend.

“We are poised to pass the toughest financial reform since the ones we created in the aftermath of the Great Depression,” Obama said at the White House, adding that the bill “represents 90 percent of what I proposed when I took up this fight … We’ve all seen what happens when there is inadequate oversight and insufficient transparency on Wall Street.”

Asked whether he expected the compromise legislation to pass the full Senate — which on May 20 approved an earlier version, 59-39, with support from four Republicans — Obama replied, “You bet.”

Republican lawmakers who serve on congressional financial panels blasted the compromise bill. “This legislation is a failure on both counts,” Sen. Judd Gregg, R-N.H. said in a statement. “It will not encourage much-needed stability and confidence in our financial markets. It will not significantly reduce systemic risk in our financial sector.”

The bill’s final passage would set off a rush of activity. Two long-standing bank regulators would be combined, and regulators would have to launch more than 20 studies on controversial topics such as limiting the risky activities of big financial firms and setting precise capital reserve standards for banks.

Some administration officials acknowledged that leaving so much decision-making in the hands of regulators could open the process to lobbying by the financial industry. Many bank supervisors, in fact, work in the headquarters of the biggest financial firms and have close relationships with the executives of the companies they regulate.

Among the first tasks for the administration would be to set up a new consumer protection bureau that would monitor credit card companies, mortgage brokers and banks to make sure consumers have clear information about financial products. The new agency, while housed in the Federal Reserve, would have its own budget and director appointed by the president and would have wide authority to write consumer protection rules and enforce them with civil penalties. It could, for instance, force mortgage lenders to be more upfront about possible interest increases in adjustable-rate loans. During the crisis, many borrowers were caught off guard by the rise in rates on such loans.

The wee hours of Friday morning brought about the final compromises between lawmakers in reconciling the chambers’ two versions of the bill.

Sen. Blanche Lincoln, D-Ark. agreed to scale back a controversial provision that would have forced the nation’s biggest banks to spin off their lucrative derivatives-dealing businesses.