An oil drilling rig at dusk near New Town, N.D. The flames from natural gas flares look like huge candles. (Michael S. Williamson/The Washington Post)

WGL Holdings, which supplies natural gas to 1.1 million customers in the Washington region, was bought by Calgary-based ­AltaGas in a cash deal worth $6.4 billion, the companies said Wednesday. They hope to close the sale by year’s end.

AltaGas Ltd. said it will relocate its U.S. power business to WGL Holding’s headquarters on Constitution Avenue in Washington. The Canadian firm may add about 20 positions over the next two years, according to executives on both sides of the deal.

The acquisition, announced after markets closed Wednesday, marks the second time in as many years that a Washington utility has been bought by a larger company.

Last year, Pepco Holdings was acquired by Chicago-based Exelon for $6.8 billion. That acquisition created the nation’s largest publicly held utility. The sale closed after an arduous approval process that included a last-minute stalemate by the D.C. Public Service Commission.

AltaGas’s acquisition of WGL will face regulatory scrutiny in Washington, Virginia and Maryland.

The natural gas market has seen great upheaval in recent years as technology — and fracking especially — has unearthed huge deposits of marketable, clean-burning natural gas across the country.

That bounty has contributed to a flurry of deals in the utility sector, including many between U.S. and Canadian companies. Midsize utilities, in particular, have become attractive takeover targets for larger conglomerates looking to diversify their businesses.

“Given all the activity in the utility sector, I can’t say it’s surprising,” Paul Patterson, an analyst with Glenrock Associates, said of the deal.

The United States has become an exporter of natural gas, something that was considered unimaginable a few years ago.

AltaGas gets about 50 percent of its revenue from its U.S. operations, including gas distribution properties in Michigan and Alaska, as well as power plants in California. It has about 500,000 gas customers. The company also owns a large battery-storage business.

“It’s a good combination from a gas utility sense,” said John O’Brien, president of AltaGas Service U.S. “WGL has good size, a lot of organic growth. You combine the things we do, like working with government agencies on generation and innovation . . . you create a platform. We believe the combination will lead to jobs in the new, advanced energy economy.”

WGL includes Hampshire Gas, Washington Gas Resources and Crab Run Gas. It employs more than 1,300 people.

It also operates a natural gas storage business and a gas pipeline division. It earned $80 million in profit in 2013 on revenue of $2.46 billion.

“Our executive leadership and management will continue to oversee operations in D.C., Maryland and Virginia,” said Adrian Chapman, WGL Holdings, president and chief operating officer.

“This will be a seamless transition with rates that are no higher as a result,” Chapman said.

WGL share prices have been on the rise in recent months on reports that the company was in negotiations with potential buyers. The stock spiked two months ago on a Bloomberg News report that said the utility was in talks to be acquired by Iberdrola, a Spanish utility company.