(Reuters) - U.S. power producer Southern Co (>> Southern Co) said it would buy AGL Resources Inc (>> AGL Resources Inc.) for about $8 billion in cash to build out its natural gas infrastructure and lower its dependence on power generation.

The combined company will operate about 200,000 miles of electric lines and 80,000 miles of gas pipelines serving about 9 million customers, making Southern Co the No. 2 U.S. utility by customer count after Exelon Corp (>> Exelon Corporation).

AGL Resources' stock rose as much as 32.4 percent to a record of $63.37 in midday trading on Monday, making it one of the few to trade higher amid a sell-off in the U.S. market.

Still, AGL Resources' shares were trading well below Southern Co's offer of $66 per share. Southern Co's shares were down 2.6 percent at $44.59.

While, demand for power weakens with increased energy efficiency, demand for gas distribution is growing as prices remain subdued due to a production glut. That has prompted many U.S. power producers to boost their natural gas infrastructure.

Through the deal, Southern Co will get access to AGL Resources' 5 percent stake in the 550-mile (885-km) Atlantic Coast pipeline, which moves gas from the Marcellus shale field in Pennsylvania.

"(The deal) gives Southern the opportunity to deepen its roots across the entire energy platform," said KeyBanc Capital Markets analyst Paul Ridzon.

Dominion Resources Inc (>> Dominion Resources, Inc.) and Duke Energy Corp (>> Duke Energy Corp), which also have stakes in the Atlantic Coast pipeline, as well as NextEra Energy Inc (>> NextEra Energy Inc) and DTE Energy Co (>> DTE Energy Co) have also formed joint ventures to build pipelines for natural gas.

AGL Resources distributes gas in Georgia, Illinois, Virginia, New Jersey, Florida, Tennessee and Maryland. Southern Co owns utilities in Georgia, Alabama, Florida and Mississippi.

The AGL Resources deal will also support Southern Co's shift away from coal, prompted by U.S. environmental regulations.

Coal accounts for about 42 percent of the company's total generating capacity, while natural gas makes up 39 percent.

Southern Co is expected to use about 1.8 billion cubic feet (bcf) of gas per day in 2015, an increase of over 20 percent in the past three years.

The combined company's natural gas usage will grow to about 4 bcf per day, Southern Co Chief Executive Thomas Fanning said on a conference call on Monday.

The deal, valued at $12 billion including debt, will form a company with 11 regulated electric and natural gas distribution centres, Southern Co said.

Citigroup Global Markets Inc is Southern Co's financial adviser, while Jones Day, Gibson Dunn & Crutcher LLP and Troutman Sanders LLP are its legal counsel. Goldman, Sachs & Co is AGL's financial adviser, while Cravath, Swaine & Moore LLP is its legal counsel.

(Writing by Swetha Gopinath in Bengaluru; Editing by Saumyadeb Chakrabarty, Ted Kerr and Savio D'Souza)

By Shubhankar Chakravorty