Strong sales of Barbie dolls and Hot Wheels cars fueled Mattel's profits in the fourth quarter, sending shares soaring as much as 20 percent after the closing bell Thursday.

Mattel reported net income of $14.9 million, or 4 cents per share, compared with a loss of $281.3 million, or 82 cents per share, a year earlier. Analysts had expected the company to post a loss of 16 cents during the quarter, according to Refinitiv.

Revenue fell 5.4 percent to $1.52 billion but still outpaced analysts' estimates of $1.44 billion.

"Our fourth quarter results demonstrate meaningful progress in executing our strategy and significant improvement over last year," Ynon Kreiz, CEO of Mattel, said in a statement Thursday. "We remain focused on advancing our strategy to restore profitability and regain top-line growth in the short-to-mid-term and are laying the groundwork to capture the full value of our IP in the mid-to-long-term."

Sales of Barbie reached a five-year high, as sales jumped 12 percent during the quarter. This is the fifth consecutive quarter of growth for the doll brand.

Hot Wheels toys also performed well during the holiday quarter, rising 9 percent.

On the other hand, sales of American Girl dolls fell 27 percent and sales of Fisher-Price and Thomas & Friends were down 13 percent. Kreiz said Fisher-Price was the brand that was most affected by the liquidation of Toys R Us last year.