NEW YORK (CNNMoney.com) -- Citigroup surprised Wall Street Friday as the embattled banking giant reported a $4.3 billion profit in the second quarter.

But the results were boosted largely by a $6.7 billion after-tax gain related to the completion of its sale of a majority of its Smith Barney wealth management division to Morgan Stanley (MS, Fortune 500).

On a per share basis, the company said it earned 49 cents a share. Analysts were expecting the New York City-based bank to record a loss of $1.07 billion, or 37 cents a share.

Citigroup CEO Vikram Pandit said that the latest results signaled that the company's turnaround efforts were finally starting to take hold, but acknowledged that there was still much work to be done, particularly in the company's consumer-related businesses.

"Sustainable profitability remains our primary goal," Pandit said in a statement.

Citigroup has earned a reputation as one of the nation's most troubled financial institutions. From the time the credit markets began to unravel in late 2007 up until the end of last year, the company lost more than $28 billion.

The bank's problems subsequently led the government to take a $45 billion stake in Citigroup in the form of preferred shares and warrants to help stabilize the bank.

Conditions at the company appear to be less dire as of late thanks to a broad recovery in banking stocks and hopes that the economy has hit bottom. But Citigroup still faces a number of difficult challenges.

Regulators have been anxious to steer the bank back towards profitability, and recent reports have suggested that the company still remains under intense scrutiny by regulators, namely the Federal Deposit Insurance Corp.

Pressure from authorities reportedly prompted Ned Kelly to step down as the firm's chief financial officer last week, with John Gerspach, Citi's chief accounting officer, taking his place.

The government will soon complete the conversion of its preferred shares in Citi into common stock, which will give American taxpayers more than one-third ownership stake in the company. The conversion was announced in late February as part of an effort to bolster Citi's capital levels.

Citi also continues to be subject to the strictest government limitations on executive compensation, which some believe will make it tough for the bank to retain key employees.

Pandit downplayed such talk during a conference call with analysts Friday, suggesting instead that the recent departures of some top Citi executives are in line with normal employment trends on Wall Street.

At the same time, the company, along with the rest of the banking sector is now facing what is shaping up to be the most sweeping government reforms for the U.S. financial system since the Great Depression.

A tale of two Citis

Friday's results, however, mark the first time the company broke out performances for its two divisions - Citicorp and Citi Holdings - since deciding to split the firm in January.

Both units were profitable during the quarter, with the smaller Citi Holdings, which included the company's infamous pool of troubled assets, earning $1.36 billion.

Still, those results were driven mainly by the Smith Barney transaction.

"It makes it look like the quarter was not horrible, but the reality is the underlying core operations are still doing quite terribly," said Michael Williams, director of research at research firm Gradient Analytics.

Williams added that JPMorgan Chase (JPM, Fortune 500) and Goldman Sachs (GS, Fortune 500), two firms that also delivered blowout quarterly results earlier this week, did so without the help of similar one-time gains.

The more stable Citicorp, which oversees, among other things, its investment bank and consumer banking businesses, earned $3.06 billion during the quarter, a decline of 11% from a year ago.

Strong trading results and resilience in Citi's fixed-income operations helped compensate for double-digit revenue declines in the company's traditional investment banking businesses, including equity underwriting, which was off 33% from the same period last year.

The issue of credit, however, remained front and center for the entire firm, much like its peers. Credit costs skyrocketed in the quarter, climbing to $12.4 billion, due in large part to loan losses. The company added $3.9 billion to its reserves to insulate itself against future loan losses.

With the recession still raging, Citigroup and other banks have been grappling with losses tied to various consumer-related loans.

Pandit and Gerspach indicated Friday that dealing with those losses, particularly in areas such as credit cards and mortgages, remained among their top priorities.

But both men were quick to point out that there were some encouraging signs, including moderation in the pace of mortgage delinquencies.

Some analysts worried, however, about signs of increased deterioration in corporate credit. The value of non-performing loans in Citi's corporate lending portfolio swelled nearly six fold to $12.4 billion in the latest quarter.

"The consumer continues to get worse, but corporate loans are getting worse at a faster rate," said Williams.

Nonetheless, Citigroup's results fall in line with the rest of its peers who reported better-than-expected second-quarter numbers this week. In addition to the strong results from Goldman Sachs and JPMorgan Chase, Bank of America (BAC, Fortune 500) revealed earlier Friday it earned $3.2 billion in the latest quarter.

Citigroup (C, Fortune 500) shares finished Friday slightly lower.