Watching the MF Global saga unfold, I had to wonder: “How was it possible for a broker dealer to tap segregated client monies to speculate in risky assets and lose billions?”

MF Global’s story, as you will soon understand it, raises serious concerns for any investor. That the activities that led to MF Global’s collapse were possibly legal (!) is stunning. The details are complex, but follow them through to the end and you will see all of the problems of our system — political corruption, excess leverage, focus on short-term profit at the expense of survival — in one sordid affair.

The MF Global story contains six elements that I found astonishing:

1. What MF Global did with client monies was “technically” legal (though it probably violated the spirit of the law).

2. Britain’s leverage loopholes provided a back door for U.S. firms such as Lehman Brothers and MF Global to “re-hypothecate” client assets — and leverage up.

3. As a result of MF Global’s lobbying, key rules were deregulated. This allowed the firm to use client money to buy risky sovereign debt.

4. In 2010, someone from the Commodities Futures Trading Commission recognized these prior deregulations had dramatically ramped clients’ exposure to risk and proposed changing those rules. Jon Corzine, MF Global’s chief executive, successfully prevented the tightening of these regulations. Had the regulations been tightened, it would have prevented the kind of bets that lost MF Global’s segregated client monies.

5. None of MF Global’s Canadian clients lost any money thanks to tighter regulations there.

6. Little noticed in this affair is (once again) the gross incompetency of the ratings agencies. Had they not been maintaining “A” ratings on Spain and Italy, MF Global could not have made its disastrous bets there.

First, let me explain hypothecation. The classic example of this occurs when you take a mortgage to buy a house. You are pledging collateral (the house) to secure a debt (the mortgage). Your collateral is “hypothetically” controlled by the bank, as the lender has the right to take possession if you default on your mortgage payments.

To equity traders, hypothecation occurs when their broker uses client stock holdings as collateral for trading or leverage. To oversimplify, buying equity with leverage involves pledging shares (collateral) to a third party (broker) in order to borrow against them. You still own the stock, but the broker can sell it if you fail to make payments when necessary. (This is the basis of a margin call and forced liquidation.)

Back to MF Global. The rules covering what a commodity firm can do regarding hypothecation are governed by two regulations. Equity and commodity brokers have, for as long as I can remember, been able to tap into client monies to make short-term purchases of U.S. Treasuries. William Cohan, author of “Money and Power: How Goldman Sachs Came to Rule the World” and “House of Cards,” the story of Bear Stearns’s demise, quoted the rule as allowing “obligations of the United States and obligations fully guaranteed as to principal and interest by the United States (U.S. government securities), and general obligations of any State or of any political subdivision thereof (municipal securities).” In other words, safe, liquid, AAA-rated investments.

Here is where the parallels to the 2007-09 collapse develop. You may recall that in 2004, the five largest banks petitioned the Securities and Exchange Commission to waive the net capitalization rules to exempt themselves from leverage limits. It was called, ironically, the Bear Stearns exemption — out went 12 to 1, in came 40 to 1, boom went the market.

Also, MF Global petitioned the CFTC to deregulate the rules covering customer accounts and segregated monies. In 2000, 2004 and 2005, the CFTC made fairly radical amendments to Regulation 1.25. These changes permitted brokers to make a much broader scope of riskier investments using client monies. Recall that the original rule allowed customer monies to be used to buy only U.S. Treasuries and investment grade munis. After the rule was amended, commodity brokers were allowed to buy investment rated “obligations of a sovereign nation.” Other rule changes allowed commodity brokers (including MF Global) to perform “internal repos of customers’ deposits” — these were the sorts of off-balance sheet maneuvers that allowed Lehman Brothers to hide $100 billion in debts from investors’ prying eyes.

Thus, these rule changes gave firms an ability to re-hypothecate (borrow) client assets, as long as they were used to buy “investment grade sovereign debt.” Amazingly, the speculative, higher yielding distressed debt, such as Spain (AA) and Italy’s (A), were still listed as investment grade by the credit-rating agencies.

So that was what MF Global did. The company bought distressed paper from European countries already in financial danger using client monies. And while it did not violate the letter of the rule changes MF Global lobbied for, it surely violated the spirit of the law.

With the regulations rewritten to include any “investment grade sovereign,” MF Global was able to go far beyond the proscriptions of the original regulations. “A-rated European sovereign debt,” despite the fact they were obviously not the equivalent of U.S. Treasuries, technically qualified.

Of course, this raises another question: If corrupt and compromised rating agencies had done their jobs — downgrade European junk to what it really was — would MF Global been able to empty client accounts?

I suspect not — their bets on Italian and Spanish sovereign debt should have been downgraded below “A” many moons ago. That it was not merely serves to remind us that these incompetent credit-rating agencies are still part of our regulatory firmament.

We have two last international aspects of this debacle to mull over: Canada and Britain.

Clients of MF Global who lived in Canada lost no money in the collapse. Canada’s regulations do not allow client-segregated monies to be borrowed for speculative purposes. Further, voting and lobbying laws there do not tolerate the sort of corrupt legislative lobbying that is rampant in the United States. Hence, regulators in Canada are far more independent and less affected by lobbying than the regulators in the United States.

Across the pond in Britain, the rules were far looser regarding re-hypothecation than even here in the States. Christopher Elias reported in Thomson Reuters that the Brits allowed U.S. brokerage firms to circumvent U.S. rules. In Britain, there is no limit to the amount of leverage against borrowed collateral through re-hypothecation. Unlimited leverage? As Elias wrote, it was “as simple as having MF Global UK Limited, an English subsidiary, enter into a prime brokerage agreement with a customer, a U.S. based prime broker can immediately take advantage of the UK’s unrestricted re-hypothecation rules.”

Finally, one last disturbing bit: The shadow banking system — the alternative system existing outside of the regulatory rules — is highly dependent on derivatives and leverage. In particular, it is highly dependent on the sort of accounting and credit games like the re-hypothecation and off-balance sheet repos that led to MF Global’s demise. Its failure revealed an enormous degree of systemic risk that remains in the current banking system.

MF Global may have been the first firm that tapped into segregated client monies to speculate and lose it all. It won’t be the last.

Ritholtz is chief executive of FusionIQ, a quantitative research firm. He is the author of “Bailout Nation” and runs a finance blog, the Big Picture.