Shares of electric car company Tesla rose sharply in the final trading session on Friday, enough to erase all of the stock's losses for the year.

Over the past week, Tesla's stock has risen about 27 percent.

Shares of the American automaker closed Friday at $251.55.

According to a press report, since Tesla's stock ended trading last year at $248.48, the stock has fallen sharply to $138.80 in April.

However, the company's stock was able to erase all losses after the strong rise during the past week.

The recent rally was sparked by a better-than-expected second-quarter delivery report.

While deliveries were still down 4.8 percent from a year earlier, the decline was less severe than in the first quarter, giving investors reason to be optimistic heading into the second half.

In April, Tesla shares hit a 52-week low after a series of worrying developments, including a decline in sales in the core auto sector in the first quarter.

The company has been downsizing through widespread layoffs, and there have been reports that Tesla has scrapped plans to soon produce a low-cost family car at its Texas factory.

Billionaire Elon Musk's Tesla is scheduled to report its second-quarter financial results after the bell on July 23.

Since last year, Tesla has been offering extensive discounts and incentives to lure customers to its aging lineup of electric vehicles, including the popular entry-level Model 3 sedans, Model Y SUVs, and the more expensive Model S sedans and Model X SUVs.