As it defends its business practices before Congress, Goldman Sachs seems to be saying: This is all the result of a big misunderstanding. On that point, both sides seem to agree — but for very different reasons.

A congressional panel Tuesday sought to portray the investment bank as a giant casino that cheated its customers, won big bets as the U.S. housing market collapsed and created complex, high-risk investments that eventually helped send the economy into a deep recession after they blew up.

In response, Goldman officials insisted they did nothing illegal, that customers knew what they were doing, and that they performed a valuable service by allowing their customers to manage business and investment risk.

Both sides may be right. But as Congress squares off on a broad package of new rules for Wall Street, and the economy and the housing market still struggle to get back on their feet, Goldman has a tough sell on its hands.

“There are plenty of impassioned defenses that are available to be made to basically talk about how the market forces worked, what happened and what needs to be done to change it,” said Jacob Frenkel, a former SEC enforcement lawyer. “I just don't think today's theater is where they're going to occur.”

Goldman officials clearly understood that dynamic at Tuesday’s hearing. As part of what will likely be a protracted legal and public relations battle, the firm’s representatives struck a conciliatory tone with their congressional inquisitors.

In his prepared testimony, Goldman CEO Lloyd Blankfein acknowledged to the Senate’s permanent subcommittee on investigations that for some people, the complicated transactions being scrutinized provide a “confirmation of how out of control they believe Wall Street has become, no matter how sophisticated the parties or what disclosures were made.”

"We have to do a better job of striking the balance between what an informed client believes is important to his or her investing goals and what the public believes is overly complex and risky,” Blankfein said in a statement released ahead of his testimony.

Blankfien's comment alluded to one of several key issues at the center of Tuesday's testimony and the debate over financial regulatory reform — whether Goldman profited by betting against its clients. Many on the committee argued that as the housing market began to crater in 2007, and mortgage-backed bonds began to lose value, Goldman unloaded them from its books, even as it made side bets against the customers buying those bonds.

Some of the e-mails presented the panel indicated the company knew it was hurting clients.

“Real bad feelings across European sales about some of the trades we did with clients,” read an e-mail attributed to Dan Sparks, former head of Goldman Sachs’ mortgage department. “The damage we did to our franchise is very significant.”

Armed with a 900-page stack of internal e-mails, presentations, memos and securities offerings, panel Chairman Carl Levin, D-Mich., set the tone early on as he grilled Sparks about another e-mail from one of Sparks' bosses describing a particular transaction as “one shitty deal."

“How about the fact that you sold hundreds of millions of that deal after your people knew it was a shitty deal,” Levin demanded after repeating the expletive a half dozen times. “Does that bother you at all?”

In response, Goldman officials patiently walked the panel through the technical details of structured finance and the purposes these deals served to help clients manage various risks.

“To the average person, the utility of these products may not be obvious,” said Fabrice Tourre, a junior Goldman executive who is the target of fraud charges by the SEC. “But they permit sophisticated institutions to customize the exposure they wish to take in order to better manage the credit and market risks of their investment holdings.”

Goldman, along with its defenders on Wall Street and Capitol Hill, argue that big investment firms allow companies to hedge the risk of a rise in interest rates or a drop in the dollar. That provides more predictability to those businesses and stability to the economy. Users of commodities like grains and oil have done this for over a century in the futures markets.

But the implosion of the financial markets in September 2008, sparked by trillions of dollars of mortgage bets that went bad, has called into question the justification for ever more complex, proprietary vehicles for hedging. One of the basic goals of proposed new financial regulations is to force those bets out in the open, standardize them like commodity futures, and put measures in place to limit the overall risk to the system that companies like Goldman can create.

Though its goal may have been to help clients manage risk, critics argue, the complex mortgage transactions engineered by Goldman merely concentrated that risk elsewhere.

“What caused the credit crisis is that more and more risk was hidden away in the (financial) system by companies that didn't have the wherewithal to meet their obligations,” said William Ackman, a hedge fund manager with Pershing Square Partners. “The risk was going into (collateralized debt obligations) and into companies like AIG Financial Products. There was a lot of ‘pass the hot potato.’ And very little attention paid to it by regulators.”

Goldman is also under fire for what has come to be known on Wall Street as “the big short” —the large-scale, negative bets Goldman and others made after the U.S. housing market began to collapse in 2007.

Short selling has long played a critical role in stabilizing financial markets by providing skeptics with an opportunity to profit when the market sets prices too high, whether for stocks or soybeans.

But with millions of homes lost to foreclosure and the housing market still struggling to get back on its feet, panel members Tuesday were quick to remind Goldman officials that their company has come to symbolize the role Wall Street played in the mortgage market meltdown.

“There is something unseemly about Goldman betting against the housing market at the same time that it is selling to its clients mortgage-backed securities containing toxic loans,” said Sen. Susan Collins, R-Maine. She cited “e-mails of Goldman executives celebrating the collapse of the housing market, when the reality for millions of Americans is lost homes and disappearing jobs.”

Lawmakers were also quick to remind the Goldman officials that, despite its claims of helping manage financial risk, U.S taxpayers were eventually left cleaning up the mess made by Wall Street’s failed bets.

The desire to prevent another Wall Street bailout is at the heart of the Capitol Hill debate over new financial regulations. Because its clients and investors assumed the government wouldn’t allow Goldman to collapse, it was able to take on the profitable business of managing financial risk.

That Wall Street needed a taxpayer backstop now undercuts part of Goldman’s argument that it performed a valuable service for its customers, the financial markets and the country.

“In many cases it's the U.S. taxpayer who is on the hook for banks making dumb deals,” said hedge fund manager James Chanos, of Kynikos Associates “At the end of the day, you can't put the taxpayer who doesn't know that he or she is at the table on these speculative kinds of trades at risk.”