Ever since the collapse of subprime mortgages took down the entire economy, the right wing has repeated a simple story: The government compelled banks to lend money to borrowers who were not qualified. When they defaulted on their loans, banks took big losses and the foreclosures cascaded into a general financial crisis.

That story has the cause and effect backward, yet former New York mayor turned presidential candidate Mike Bloomberg has embraced it. In a 2008 speech at Georgetown that recently surfaced, he attributed the collapse to “pressure on banks to make loans to everyone.” He defended redlining entire neighborhoods as sound banking practice. As Bloomberg explained it, “Redlining, if you remember, was the term where banks took whole neighborhoods and said, ‘People in these neighborhoods are poor, they’re not going to be able to pay off their mortgages, tell your salesmen, “Don’t go into those areas.” ’ ”

“And then Congress got involved — local elected officials as well — and said, ‘Oh, that’s not fair, these people should be able to get credit.’ . . . Banks started making more and more loans where the credit of the person buying the house wasn’t as good as you would like,” Bloomberg said.

Everything about that claim is wrong. I should know, because I wrote the law.

In the 1970s, community groups came to Congress to protest the fact that whole neighborhoods were being denied credit by banks. I happened to be working as chief investigator for Sen. William Proxmire, then the chair of the Senate Banking Committee. After several days of hearings and extensive investigation, we wrote and persuaded Congress to enact two laws.

The first, the Home Mortgage Disclosure Act of 1975, required banks to disclose where they were lending. The second, the Community Reinvestment Act of 1977 (CRA), created an affirmative obligation not to redline and to provide credit without regard to location, “consistent with the safe and sound operation of such institutions,” which is to say with responsible lending standards.

We made sure to add that phrase so the legislation would neither pressure banks to make bad loans nor be faulted for doing so. Regulators defined that phrase to mean lenders should serve their entire communities, but not water down sound underwriting standards. The banks regularly received CRA scores, which were used to permit or deny mergers and acquisitions. One of the constructive effects of the CRA was the creation of a whole generation of loan officers who took pride in being able to extend credit to low- and moderate-income borrowers without subjecting the bank to undue risk.

It wasn’t until the 1980s and 1990s that Wall Street investment bankers and local mortgage originators came up with the scheme that led to the subprime collapse. This was all about inflating profits and passing along risks to someone else. It had nothing whatever to do with the Community Reinvestment Act.

The investment bankers would bankroll local mortgage bankers to make subprime loans with low “teaser” rates. By definition, a subprime loan is a loan to a customer who would not qualify for credit at the usual rates. After a few years, the interest rate on these loans would double or triple. Many borrowers defaulted.

How could lenders make money on a product with a high risk of default? The investment bankers packaged the loans into bonds, known as collateralized debt obligations. These were blessed with Triple-A ratings by private credit rating agencies and bought by unsuspecting investors all over the world.

The investment bankers got the loan originators off the hook, and the bond buyers got the investment bankers off the hook. So local lenders could make unsound loans and investors could underwrite them, making a lot of money and passing along the risk to someone else. The whole process was corrupt, but in an era of deregulation, the regulators looked the other way.

None of this derived from — or was even related to — the Community Reinvestment Act. The mortgage bankers and investment bankers at the heart of the subprime scheme were not even covered by the Community Reinvestment Act, which applied only to commercial banks and savings and loans.

As the authoritative report of the Financial Crisis Inquiry Commission later revealed, the lenders and brokers who participated in the subprime scam did it to make scads of money with no risk, not because of prodding by the CRA — which expressly prohibited unsound loans. The report explained: “They competed by originating types of mortgages created years before as niche products, but now transformed into riskier, mass-market versions.” The CRA, according to the report, was not a factor.

A second federal law, ignored in the era when Alan Greenspan chaired the Federal Reserve, prohibited unsound lending practices in mortgage lending even more explicitly than the CRA. The Home Ownership and Equity Protection Act of 1994 expressly prohibited deceptive loan marketing to low-income borrowers. But the act was not enforced.

So, contrary to Bloomberg, the problem was not Congress imposing unsound mandates on bankers. It was bank regulators ignoring legislated requirements intended to protect consumers from abusive banker practices.

The rate of minority and low-income homeownership successfully increased through the 1990s with low default rates, before the invention of subprime, thanks to careful lending standards. It was the regulatory failure to police lending standards and the subprime debacle that crushed the hopes and homes of minority homeowners, not the CRA.

Bloomberg’s words didn’t just set back his candidacy with minority voters. They also demonstrate why the last person Democrats need as their nominee in 2020 is a corporate billionaire whose first instinct is to excuse the toxic practice of bankers — and blame the bankers’ victims.