FINANCIAL reform is coming to America. On May 20th, after more than three weeks of often rancorous debate, the Senate approved the biggest overhaul of the financial system since the Great Depression, by 59 votes to 39. Its bill must now be reconciled with one passed by the House of Representatives in December. The result will be Barack Obama's second big legislative victory of the year, after the passage of health-care reform in March.

Tim Geithner, Mr Obama's treasury secretary, praised Chris Dodd and Harry Reid, the Democratic senators who steered the 1,500-page Restoring American Financial Stability Act to a successful vote, for their “tremendous leadership”. The administration has reason to be pleased, since the bill largely mirrors the reform blueprint it had been pushing.

As with most bills, this one has its share of pork and irrelevant provisions, including one requiring buyers of Congolese minerals to prove that the money they hand over is not being used to fund militant groups. But there is much meat at its heart. The bill would beef up the system for monitoring systemic risks. It would empower the Federal Deposit Insurance Corporation to wind down failing financial giants, imposing losses on creditors as well as shareholders. It would create an independent consumer financial-protection bureau. And it would toughen up oversight of derivatives, requiring most contracts to be channelled through clearing houses and traded on exchanges or exchange-like platforms.

Could this bill have prevented the crisis? Not by itself. Some of the most important reforms are outside its purview. Toughened-up capital and liquidity standards for banks will be hammered out by regulators from around the world in Basel. The Obama administration's proposed tax on big banks will likely be advanced in different legislation. One glaring omission from the Senate and House bills is a plan to deal with Fannie Mae and Freddie Mac, the giant, accident-prone mortgage agencies now under government conservatorship.

The most important component aimed at preventing another crisis is “resolution authority”, under which any big financial company, not just a bank, can be seized and wound down in an orderly way. Lack of such authority led to the shambolic failure of Lehman Brothers and the controversial bail-out of AIG. To win Republican support, however, Mr Dodd made the process so harsh for unsecured creditors that they might flee if they sense panic building—forcing the authorities, again, to use ad-hoc measures. Left unanswered is how bail-outs will be paid for. The House version of the bill requires banks to chip in to a $150 billion up-front fund. The Senate bill envisages the costs being recouped afterwards, another concession to Republicans.

The new consumer-protection bureau should help to close the gap between well-regulated banks and poorly regulated mortgage brokers and finance companies, which led the race to the bottom in loan-underwriting standards. But many firms are exempted from its authority. Small banks must follow its rules but will be supervised by existing regulators. And the industry gripes that there is remarkably little independent oversight of the bureau, should it run amok with new regulations that stifle legitimate products. The Senate bill puts the bureau inside the Federal Reserve, though it gives the Fed little say in its direction; in the House version, the bureau stands alone.

Surprisingly, given the depth of congressional animosity towards it, the Fed emerges as a big winner. It keeps all its existing bank-supervision powers (except for consumer protection) and gets new ones over systemically important non-banks. In a crucial victory, the Fed and the White House fought off a provision that would have allowed intrusive congressional audits of the central bank's most delicate monetary-policy decisions. However, such a provision remains in the House version of the bill.

As for Wall Street itself, the outcome is worse than initially expected but better than it might have been—though uncertainties remain. Bankers had hoped that the bill emerging from the Senate-usually the more measured of the two chambers-would be more bank-friendly than the House version. But a flurry of draconian amendments was offered in recent weeks amid a surge in anti-bank sentiment (fuelled by fraud charges against Goldman Sachs) and political populism in the run-up to congressional primaries. Among those approved was one requiring the Fed to regulate debit-card fees, another setting minimum mortgage-underwriting standards (and banning no-documentation “liar loans”) and a third requiring credit ratings of asset-backed securities to be assigned by a board within the Securities and Exchange Commission. But a proposal to cap banks' maximum size was defeated, as was one that would have placed restrictions on credit-card interest rates.

But some of banks' biggest worries remain unresolved. They are resigned to accept some form of the “Volcker rule”, which would restrict their proprietary trading and investment in hedge funds and private equity. A particularly tough version of the rule was rejected just before the Senate vote, but its authors hold out hope that it can be inserted during the weaving-together of the House and Senate bills. The Volcker rule and other looming restrictions could collectively cut large banks' profits by as much as 15-20% (not counting returned capital from shed businesses), reckon analysts at Morgan Stanley.

Wall Street's biggest concern is a provision banning deposit-takers from trading credit-default swaps, interest-rate swaps and the like. Introduced by the head of the Senate Agriculture Committee some weeks ago, it was expected that this would fall by the wayside during debate. But it proved stubbornly persistent, making it into the bill as passed. Ostensibly aimed at raising a firewall between run-of-the-mill retail banking and “casino” activities, such a prohibition would hinder risk management as well as speculation, banks argue.

All eyes will now be on the “conference” process that will likely be used to iron out differences between the two bills over the next week or two. This will provide one last lobbying opportunity to Wall Street, which has already spent hundreds of millions trying to influence lawmakers, to the president's chagrin. Banks will focus much of their effort on reversing the swap-dealing ban (which is also opposed by their regulators). Where the two chambers differ, the Senate prevails as a rule—though Barney Frank, the architect of the House bill, has said he will fight to preserve some of his provisions. Once Mr Obama signs the law, many of its vaguer provisions will have to be fleshed out by financial regulators, a process that could take many months. There are plenty of ambiguities to be tackled, for instance the bills' loose definition of “swap” and “major swap participant”.

After the Senate bill was passed, Mr Obama pledged to “ensure that we arrive at a final product that…secures financial stability while preserving the strengths and crucial functions of a financial industry that is central to our prosperity and ability to compete in a global economy.” That remains to be seen. If the history of financial legislation is a guide—just think Sarbanes-Oxley—the new law will have more than a few unintended consequences. For now, though, the White House can revel in a political triumph that a year ago seemed to many to be beyond reach.