NEW YORK ( TheStreet) -- Tesla Motors ( TSLA - Get Report) cofounder Elon Musk is investing $100 million in the company's stock as the electric car maker uses a sharp rise in its shares to issue stock and repay government loans.

After the market close on Wednesday, Tesla said it will issue up to 3.1 million new shares and $450 million in convertible notes, in a capital raise that's been speculated amid a sharp run up in the automaker's stock.

Elon Musk, Tesla's chief executive and cofounder, is committing to buy $100 million in Tesla stock.

Musk will purchase $45 million of Tesla's stock in the share offering and an additional $55 million in shares directly from the company in a private placement, according to a press release.

In total, Tesla expects to raise about $830 million through the capital raise, in a move to repay the company's outstanding loans with the Department of Energy. Proceeds will also be used for general corporate purposes, Tesla said in a statement.

The interest rate, conversion price and other terms of the notes on Tesla's convertible note offering were not announced. Tesla also didn't indicate a price for its secondary stock offering.

Tesla shares closed Wednesday trading up nearly 2% to $84.84. In after-hours trading, shares gained over 5% to $89.39, on news of the capital raise.

Goldman Sachs ( GS - Get Report) will lead Tesla's secondary stock offering, while it, Morgan Stanley ( MS - Get Report) and JPMorgan ( JPM - Get Report) will act as joint book runners in the convertible note offering.

Tesla recently announced it will repay $465 million in loans received under the Department of Energy's Advanced Technology Vehicle Manufacturing Program (ATVM) by late 2017, five years ahead of schedule.

Were Tesla to repay its ATVM loans in full ahead of a 2022 maturity, deeply discounted warrants held by the Department of Energy (DoE) for over 3 million Tesla shares will be cancelled, according to an April statement from company spokesperson Shanna Hendriks.

The government holds 3,090,111 Tesla warrants, some of which Tesla says have an exercise price of $7.54 and some carry an exercise of price of $8.94 a share, according to the company's most recent annual report. The warrants currently are worth over $200 million at Tesla's current price.

"Far from being worried about our survival, the DoE is highly bullish about our future and doesn't want us to delay early repayment of the loan if we have the cash on hand to do so," Musk wrote in October.

" We have a duty at Tesla, having accepted this loan as a portion of our capital, to repay it at the earliest opportunity."

For more on Tesla see the government's Buffett-less warrant contracts.

Earlier in May, Tesla sharply beat first quarter earnings expectations as sales jumped 83% year-over-year to $562 million and the company earned 12 cents a share in profit.

Analysts polled by Thomson Reuters expected the Palo Alto, Calif.-based Tesla to earn 4 cents a share on $499.55 million in revenue.

Tesla said it produced 400 or more Model S vehicles a week, recognizing 4,900 cars as revenue and raised its global deliveries guidance to about 21,000 vehicles for 2013, up from its prior goal of 20,000.

Shares have gained over 55% in the past five trading days on better than expected earnings and a near-perfect score from Consumer Reports on the company's all-important Model S roadster.

-- Written by Antoine Gara in New York