(Reuters) - Community Health Systems Inc (>> Community Health Systems), the No. 2 U.S. for-profit hospital operator, said on Tuesday it would buy smaller rival Health Management Associates Inc (>> Health Management Associates Inc) for $3.9 billion (2.5 billion pounds) to strengthen its base as the country's healthcare system is overhauled under President Barack Obama.

Community Health said that based on Monday's stock prices, it would pay $13.78 per share in cash and its own stock. The deal would give Health Management shareholders a 16 percent stake in the new company and an additional contingent value right worth up to $1 per share.

Health Management fell 5 percent to $14.20 in premarket trading, while Community Health was lightly traded.

Health Management had faced a looming proxy fight launched by hedge fund Glenview Capital Management to replace its entire board of directors. In June, Health Management said it hired Morgan Stanley (>> Morgan Stanley) and law firm Weil, Gotshal and Manges to consider strategic alternatives in response to Glenview's campaign.

Both chains operate hospitals primarily in smaller cities and rural areas. Health Management has a strong presence in the U.S. Southeast, including Florida.

The agreement has been approved by both boards of directors and is expected to close by the end of the first quarter of 2014.

(Reporting by Susan Kelly in Chicago and Caroline Humer in New York; Editing by Gerald E. McCormick and Jeffrey Benkoe)