Duke Energy Corp. said it would buy Piedmont Natural Gas for $4.9 billion, as the electric utility tries to bulk up on gas assets that offer reliable profit margins and good growth prospects.

The deal marks the second time this year that an electric utility has agreed to buy a gas-distribution company already operating on its home turf. In August, Southern Co. agreed to buy AGL Resources Inc. for $8 billion; both companies are based in Atlanta.

Duke...