A logo for athenahealth is displayed on a computer on Monday in New York. Athenahealth shares soared Monday after the struggling medical billing software maker received a $5.7 billion cash buyout offer. Credit: Jenny Kane | AP

Private-equity firm Veritas Capital and Elliott Management Corp. will acquire athenahealth Inc. for $135 per share, ending a months-long, sometimes-contentious process to push the health records company into a sale.

The all-cash transaction values athenahealth at about $5.7 billion, the firms said in a statement announcing the transaction Monday. The price is a 12 percent premium to where the shares closed on Friday.

Athenahealth rose 9.2 percent to $131.45 at 9:04 a.m. in New York, before the market opened.

[Subscribe to our free morning newsletter and get the latest headlines in your inbox]

After the deal closes, athenahealth will be combined with Virence Health, Veritas’s health care services company, the firms said. Virence offers hospitals and physician practices services to manage their revenue and workflow. The combined company will keep the athenahealth name, and will be led by Virence Chief Executive Officer Bob Segert.

A sale has been pushed by Elliott, the sometimes-activist fund run by billionaire Paul Singer. Earlier this year, New York-based Elliott went public with a 9 percent stake in athenahealth, and said it was prepared to offer $160 per share for the company, subject to due diligence. Elliott said that the company, which provides online business services including billing for health care providers, had been mismanaged and failed to grow as much as it should have.

Athenahealth refused Elliott’s proposal. The company has been formally exploring a sale since June, when Chief Executive Officer Jonathan Bush stepped down following allegations of misconduct.

[How one firm helped a Maine city recover from the loss of its biggest employer]

“Operating as a private company with Veritas’s ownership and support will provide Athenahealth with increased flexibility to achieve our purpose of unleashing our collective potential to transform health care,” said Jeff Immelt, the former General Electric Co. CEO who has been athenahealth’s executive chairman.

Elliott’s private equity arm, Evergreen Coast Capital, will keep a minority stake in the new company. The deal is expected to close in the first quarter of 2019, the firms said.