Iberdrola USA, the parent company of Central Maine Power Co., is buying a utility that has 725,000 customers in Connecticut and western Massachusetts.

The deal is valued at about $3 billion and will produce a new publicly traded company led by James P. Torgerson, chief executive officer of UIL, the utility that Iberdrola is acquiring. UIL provides electricity and gas transmission in the two states where it operates.

Iberdrola will give UIL stockholders a share in the newly formed company for each share they held in UIL stock, plus $10.50 per share. That represents a premium on UIL stock of about 25 percent, the company said.

The deal has been approved by the boards of both companies.

Iberdrola is based in Spain. Its U.S. subsidiary owns CMP, New York State Electric & Gas and Rochester Gas & Electric. UIL owns United Illuminating, Southern Connecticut Gas, Connecticut Natural Gas and Berkshire Gas.

The combined company will have 3.1 million electricity and gas customers in Maine, Massachusetts, Connecticut and New York, and a rate base of about $8.3 billion. In a statement, Iberdrola USA said the combined company will invest $6.9 billion in infrastructure and other capital expenditures over the next five years.

The statement also said that the combined company will continue to maintain its offices in Maine, Connecticut, Massachusetts and New York and honor its contracts with UIL unions.

The deal needs approval from regulators and UIL shareholders, and is expected to close by the end of this year.