In a show of strength ahead of its expected initial public offering, General Motors on Thursday posted a second-quarter profit of $1.3 billion, the auto maker’s biggest profit since 2004.

GM, which is attempting to regain its independence from the U.S. government, said it earned $1.3 billion last quarter, a huge improvement from a year earlier when it lost almost $13 billion. GM, which made $865 million in the first quarter, also posted its first back-to-back quarterly profits since 2004.

Earnings before interest and taxes, or EBIT, totaled $2 billion. Revenue soared 43% to $33.2 billion.

“I am pleased with our progress on achieving our business objectives,” Chris Liddell, vice chairman and chief financial officer, said in a statement. “We have delivered strong product, maintained cost discipline, progressed strategic initiatives such as restructuring Europe and acquiring AmeriCredit, and delivered two consecutive quarters of profitability and positive cash flow.”

GM, which received a $50 billion rescue from the U.S. last year, said its North American operations posted EBIT of $1.6 billion, up from $1.2 billion in the first quarter of 2010. The auto maker’s European unit posted a loss before interest and taxes of $200 million, a slight improvement from a loss of $300 million in the previous quarter. EBIT at GM’s international business eased from $1.2 billion in the first quarter to $700 million last quarter.

Shares of rival Ford (NYSE:F) were down 1.8% to $12.18 Thursday morning amid another selloff on Wall Street. By comparison, Toyota’s (NYSE:TM) stock gained 1.1% to $70.57.

The strong results from GM come as the auto maker attempts to project confidence ahead of its IPO, which should clear the way for the U.S. to begin to unwind its 61% stake in the company.

According to The Wall Street Journal, GM has secured a $5 billion credit facility with a consortium of banks, clearing another hurdle for the IPO. A credit facility allows companies to borrow for any reason and provides a cushion for the balance sheet.

Ten banks are contributing to the credit facility, including Bank of America (NYSE:BAC), Morgan Stanley (NYSE:MS) and JPMorgan Chase (NYSE:JPM), the paper reported. Now that it has secured the credit facility, GM is reportedly aiming to file registration papers for an IPO on Friday.

The Treasury Department is looking to sell off at least $10 billion of its stock after the IPO, which is expected later this year, the Journal reported.