Greatbatch Inc. reported a $5.6 million loss in the fourth quarter, stemming from the cost of shutting two troubled factories in Switzerland, but earnings from the company’s other operations still exceeded expectations.

The battery and medical device maker recorded a fourth-quarter loss of 23 cents per share, compared to a profit of $5.6 million, or 24 cents per share, a year ago. Greatbatch’s sales rose 12 percent from a year ago, to $159 million.

Thomas J. Hook, Greatbatch’s president and chief executive officer, called the fourth-quarter results “a step in the right direction.” He said the company has completed all of its major plant consolidations, which began in 2007.

Michael Dinkins, the chief financial officer, said the company has finished the transfer of its Swiss orthopedic operations to plants in Fort Wayne, Ind., and Tijuana, Mexico. The shutdown of the poorly performing Swiss plants was announced last July.

“We now feel that the worst is behind us for this product line and expect to see organic growth resume in 2013,” Hook said in a conference call.

Greatbatch last summer moved its corporate headquarters to Texas, but nearly all of its other operations remain in Clarence.

Excluding the costs associated with the Swiss plants, Greatbatch reported adjusted earnings per share of 53 cents, beating analysts’ expectations by 3 cents. The company’s sales of $159 million fell short of the $161 million expected by analysts.

Greatbatch’s implantable medical sales fell 2 percent to $119 million, while its commercial sales nearly doubled to $40 million, bolstered by the acquisition of Micro Power in December 2011.

During all of 2012, Greatbatch spent $28 million on medical device research and development, and $5 million for design verification testing. In 2011, the company spent a total of $27 million on those two categories.

Hook said a large portion of those expenses went toward development of Algostim, a spinal cord stimulator. He said the company will provide much more information about Algostim during its “investor day” presentation on March 18.

“We believe Algostim’s unique features and benefits will allow us the right commercial partner to capture significant market share in today’s $1.3 billion spinal cord stimulation market, which continues to see double-digit market growth,” Hook said.

For all of 2012, Greatbatch reported a net loss of $4.8 million, compared to a $33.1 million profit the year before. Its full-year sales were $646 million, up 13.5 percent from $569 million a year earlier.

The company reiterated its earlier forecast that its sales growth would slow this year to between 2 percent and 5 percent, with revenues during 2013 expected to range between $660 million and $680 million.