Mattel Inc. (MAT) shares reached their highest level in five months Friday after the toymaker posted stronger-than-expected fourth-quarter earnings thanks in part to the best sales for its iconic Barbie doll in at least five years.

Mattel posted a surprise profit of 4 cents per share for the three months ended in December, against a Wall Street forecast of a 16 cents per share loss, even as revenues fell 5.4% to $1.52 billion. Barbie sales, however, surged 15% from the same period last year as one of the world's most-recognized toys continued to benefit for a make-over that reflects the growing diversity of its customer base. Hot Wheels sales, Mattel's other top brand, rose 12% to $286.8 million.

"In terms of brand highlights, 2018 was a great year for Barbie, which sustained growth and continued momentum globally. Barbie worldwide gross sales were up 15% both for the quarter and the full year in constant currency," said CEO Ynon Kreiz told investors on a conference call late Thursday. "Barbie was the number one global fashion doll property in 2018 according to NPD. We look forward to celebrating her 60th anniversary throughout 2019 with a number of exciting product launches and events."

Mattel shares rose 23% to close at $15.23, the highest since October 1 and a move that values the El Segundo, California-based group at just under $6 billion.

The notable weak spot in the quarter, however, was the 15% year-on-year decline in sales for Fisher-Price and Thomas & Friends, to $352.2 million, which Kreiz said was largely linked to the liquidation of Toys R Us in the autumn of last year. 

"Fisher Price was one of the Mattel brands most heavily impacted by the liquidation of Toys "R" Us as well as challenges we have faced in China," he said. "As the effects of Toys "R" Us moderate and we work through channel inventory in China, the brand will be in a better position to restore growth."