Back in September of 2008, at the height of the credit crisis, Berkshire essentially loaned Goldman $5 billion at an interest rate of 10 percent a year. (That money was repaid in 2011.)

As part of its vote of confidence, Berkshire also received warrants giving it the right to buy another $5 billion worth of common stock at $115 per share anytime in the following five years. That purchase would work out to over 43 million Goldman shares — roughly a 10 percent stake in the company.

With Goldman shares now around $145, the below-market purchase price would generate a paper profit for Berkshire of around $1.3 billion.

Goldman Reworks Buffett's $5 Billion Stake

A crisis-era deal has been amended between Warren Buffett and Goldman Sachs, reports CNBC's Mary Thompson.

Under today's deal, Berkshire won't have to spend that $5 billion to purchase shares. Instead, when the five-year warrants are about to expire this fall, Buffett's company will get the equivalent of its "paper profit" in Goldman shares.

So, if the transaction was executed at today's prices, Berkshire would get $1.3 billion worth of Goldman stock. That would be a stake of almost two percent, and would make Berkshire one of Goldman's 10 biggest shareholders.

Berkshire keeps its $5 billion in cash, and Goldman avoids what would have been a major dilution of its stock.

"We intend to hold a significant investment in Goldman Sachs, a firm that I did my first transaction with more than 50 years ago."-Warren Buffett, Berkshire Hathaway Chairman & CEO

Buffett generally doesn't think much of Wall Street types who manage other people's money. He even has a $1 million 10-year bet underway in which he backs a low-cost S&P stock index fund versus several hedge funds. (After five years, he's now winning that wager.)

Buffett, however, does have a soft spot for Goldman.

In a statement, the Oracle of Omaha said that he intends to hold "a significant investment in Goldman Sachs, a firm that I did my first transaction with more than 50 years ago. I have been privileged to have known and admired Goldman's executive leadership team since my first meeting with Sidney Weinberg in 1940."

Weinberg, sometimes called "Mr. Wall Street," was Goldman's CEO from 1939 until he died in 1969.

In 2010, when Goldman was accused of fraud by the SEC, Buffett defended the company saying, "It's hard for me to get terribly sympathetic" with the alleged victim in the case. He did acknowledge, however, that Goldman had "lost the PR battle" at that point. (In July of 2010, Goldman agreed to pay a record $550 million to settle the SEC's charges, but didn't admit any legal wrongdoing.)

For years, Goldman also employed one of the few investment bankers to win Buffett's respect. In his 2003 letter to Berkshire shareholders, Buffett wrote of Byron Trott — then Goldman's vice chairman of investment banking — that "he understands Berkshire far better than any investment banker with whom we have talked and – it hurts me to say this – earns his fee."