In late 2007, as the mortgage crisis gained momentum and many banks were suffering losses, Goldman Sachs executives traded e-mail messages saying that they would make “some serious money” betting against the housing markets.

The messages, released Saturday by the Senate Permanent Subcommittee on Investigations, appear to contradict statements by Goldman that left the impression that the firm lost money on mortgage-related investments.

In the messages, Lloyd C. Blankfein, the bank’s chief executive, acknowledged in November 2007 that the firm had lost money initially. But it later recovered by making negative bets, known as short positions, to profit as housing prices plummeted. “Of course we didn’t dodge the mortgage mess,” he wrote. “We lost money, then made more than we lost because of shorts.”

He added, “It’s not over, so who knows how it will turn out ultimately.”

In another message, dated July 25, 2007, David A. Viniar, Goldman’s chief financial officer, reacted to figures that said the company had made a $51 million profit from bets that housing securities would drop in value. “Tells you what might be happening to people who don’t have the big short,” he wrote to Gary D. Cohn, now Goldman’s president.