TORONTO — BlackBerry-maker Research In Motion posted another large loss in the second quarter on Thursday but not as bad as analysts expected.

RIM's stock surged more than 18 percent to $8.44 in after-hours trading.

The company reported Thursday that it lost $235 million, or 45 cents a share, in its fiscal second quarter, which ended Sept 1. That compares with a profit of $419 million, or 80 cents per share, a year ago.

RIM reported revenue of $2.9 billion.

Analysts polled by FactSet expected a loss of 47 cents on revenue of $2.49 billion.

RIM said it shipped 7.4 million BlackBerry smartphones in the quarter, down from 10.6 million in the same period last year. Some analysts predicted RIM would ship about 6.4 million as the company prepares to launch new BlackBerrys deemed critical to its survival.

The Canadian company has struggled in recent years to compete with flashier phones like Apple's iPhone and phones running Google's Android software. RIM is banking its future on its much-delayed BlackBerry 10 platform, which is meant to offer the multimedia, Internet browsing and apps experience that customers now demand. The new smartphones are due out early next year.

RIM no longer gives guidance but said in a release it expects "continued pressure on operating results for the remainder of the fiscal year."

"Despite the significant changes we are implementing across the organization, our second quarter results demonstrate that RIM is progressing on its financial and operational commitments during this major transition," chief executive Thorsten Heins said in a statement.

Comment on this story

"Make no mistake about it, we understand that we have much more work to do, but we are making the organizational changes to drive improvements across the company, our employees are committed and motivated, and BlackBerry 10 is on track to launch in the first calendar quarter of 2013."

Jefferies analyst Peter Misek said RIM did a great job in the quarter, considering the challenges it faced. He noted, however, that doesn't account for much because the new smartphones are not out yet.

"They are driving sales in emerging markets and we think they will continue to lose subscribers in developed markets. It doesn't tell you anything about the long term success of the platform or the company. It's the first good quarter in how many quarters," Misek said.