Pepco Holdings, the century-old Washington-based utility scorned in recent years for its service lapses, has agreed to be acquired by nuclear energy giant Exelon in an all-cash deal that would cement Chicago-based Exelon’s hold on the Mid-Atlantic power market.

The takeover would mean the end of independence for one of the city’s oldest institutions, but it could bring improved service for consumers and a modest premium for Pepco shareholders.

The deal, however, is not likely to slow requests for rate hikes and surcharges that Pepco and Exelon have sought recently to address nagging reliability issues in the wake of storms.

Exelon said the all-cash transaction is based on a $27.25 share price that represents a 24.7 percent premium to Pepco Holdings’ closing price of $21.85 on April 25. That would value the deal at about $6.8 billion based on the number of outstanding shares reported in Pepco’s most recent securities filing. The deal has been approved by the boards of directors at both companies and must still be endorsed by Pepco shareholders. Exelon also agreed to provide up to $100 million — or about $50 a customer — to give Pepco customers benefits such as rate credits, assistance for low income customers and energy efficiency measures.

“As part of this transaction, Exelon has committed to provide what our customers most want: investments in infrastructure improvements, continuation of our long tradition of philanthropy in our communities and direct customer benefits of $100 million,” Joseph M. Rigby, the chairman, president and chief executive officer of Pepco Holdings, said in a statement. “Our shareholders will benefit from an immediate cash premium, and employees should enjoy even more opportunities as part of a larger company.”

Exelon’s deal to buy Pepco comes amid growing pressure on utilities to figure out how to increase profits at a time when energy efficiency and a sluggish economy have rendered electricity consumption stagnant.

Many companies have turned to strategic acquisitions.

Exelon, which owns 23 nuclear power plants, is acquiring a gas and electric transmission company that is one-fifth its size. Pepco, having sold its power plants several years ago, no longer generates its own electricity and instead buys it from others. But Pepco, which traces its history to a streetcar company from the late 19th century, has more than 2 million customers in an arc stretching from Washington and its Maryland suburbs, east to the Delaware shore and north to New Jersey.

The agreement comes three years after Exelon bought Baltimore-based Constellation Energy Group, parent of Baltimore Gas and Electric, for $7.9 billion in a deal that extended Exelon’s reach into 38 states and two Canadian provinces.

Like the earlier merger, this one will require approval from the Federal Energy Regulatory Commission, which will weigh Exelon’s potential market power. It also will require an antitrust review by the Justice Department and the Federal Trade Commission, as well as approval by the public service commissions in three states and the District of Columbia. In the past, some mergers — such as Florida Power & Light’s bids for Constellation and Entergy — have been scuttled by the failure to obtain approvals.

Wells Fargo senior analyst Neil Kalton issued a note to investors Monday cautioning that “the regulatory approval process would likely be thorny as [Pepco] has four jurisdictions that are considered to be relatively tough.”

On a conference call with reporters Wednesday, Exelon president and chief executive Christopher Crane expressed confidence the companies could win approval from regulators, citing Exelon’s experience on the acquisition of Constellation.

“We have a skilled regulatory team. We’ll work closely with the regulator. We would not do this if we could not see a path toward closure,” Crane said.

The companies said they hoped to close the deal by the third quarter of 2015.

The latest takeover marks another step toward the reintegration of regulated utilities with power generation companies.

About a decade ago, the big talk in the utility business was about tossing off the yoke of regulation and becoming independent, or “merchant,” power companies that competed to sell electricity to hungry grids. Proponents said the shift would allow consumers to shop around for the best deal.

Utilities raced to position themselves in this new world. Some, such as Pepco and BGE, got out of the power generation business, while others focused on producing energy for others to distribute.

Cheap natural gas from the shale gas boom and a growing amount of wind energy have decimated those strategies. Gas prices have dropped so low that merchant power plants relying on other fuel sources — including coal and nuclear — have been forced to shut down or sell electricity at bargain-basement rates.

So companies with excess power have been seeking to return to regulated markets, where public service commissions can guarantee modest but dependable rates of return. Consumers are more protected against big swings in rates, but they lose some price power.

A Moody’s Investor Service report on Exelon in February said the company’s three regulated subsidiaries — BGE in Maryland, Commonwealth Edison in Illinois and Peco Energy in Pennsylvania — “mitigate the risks of Exelon’s more challenged unregulated business” and provide “a solid foundation for the unregulated business to wait for better market conditions.”

Other major utilities have merged in recent years, including Duke Energy and Progress Energy; Northeast Utilities and NStar; NRG and GenOn; and PPL and two Kentucky utilities.

Exelon, guided first by longtime chief executive John Rowe and now by Crane, was formed by the 2000 merger of Chicago’s Unicom with Peco Energy, Philadelphia’s electric utility, creating a Fortune 100 company with the nation’s largest fleet of nuclear power plants. In 2009, Exelon dropped a hostile takeover bid for NRG after it failed to win support from NRG shareholders.

Exelon’s vast portfolio of nuclear power plants generates 55 percent of the power it sells. Its reactors are at 14 facilities in Illinois, Maryland, Nebraska, New Jersey, New York and Pennsylvania. It also owns 32 fossil fuel plants that stretch from Utah to Texas to Massachusetts.

Nuclear power, while it does not emit carbon dioxide or other greenhouse gases, does not count toward the renewable-electricity standards more than 30 states have adopted. So Exelon also owns and runs the nation’s largest urban solar power plant in Chicago, and has another solar plant in development in California.

The Pepco acquisition could have a big impact on the Washington area, where Pepco has been a philanthropic force, employs 3,242 and has extensive lobbying and political activities.

The company has been part of the region’s fabric, is represented on various local business and charitable boards and even served as a vehicle for political candidates such as Sharon Pratt Kelly, who was Pepco’s vice president for community relations when she successfully ran for mayor.

The Pepco board is peopled with some of the region’s biggest players, including Lawrence Nussdorf, chief operating officer of the construction giant Clark Enterprises; Terence Golden, founder of Bailey Capital and former chairman of Host Hotels and Resorts; and Barbara Krumsiek, president of Calvert Investments. Pepco chief executive Rigby in January announced plans to retire next year.

Pepco Holdings subsidiaries include Pepco, which delivers electricity to 788,000 customers in Montgomery and Prince George’s counties and the District, and Delmarva Power, serving 501,000 customers in Delaware and the Delmarva Peninsula and 124,000 natural gas delivery customers in northern Delaware. Its Atlantic City Electric subsidiary blankets southern New Jersey, serving 547,000 customers.

In the conference calls with reporters, Rigby and Crane said the customer billing process and names of the local companies would remain the same, and union contracts would be honored. They said that there would be a reduction in the number of employees but it was “premature” to say what the impact would be. They said that “synergies” would produce $80 million a year in savings that would be passed on to customers.

Pepco has gone through several weather-related challenges in recent years, with trees and branches taking out power lines and electricity during thunderstorms, ice and hail, the “Snowmageddon” of 2010, Hurricane Irene in 2011, and a derecho and Hurricane Sandy in 2012.

An investigation by The Washington Post concluded that Pepco’s reliability was among the worst in the nation and that the company ranked at or near the bottom nationally among electric utilities in keeping power on and restoring lights once electricity goes out.

The Post found that the average Pepco customer experienced 70 percent more outages than customers of other big-city utilities. And the lights stayed out, on average, more than twice as long.

The company has since ramped up public relations efforts and stepped up its investment in infrastructure, seeking special surcharges to cover some of the costs. On the customer relations front, Pepco has begun making automated telephone calls and conducting a social-media blitz to update customers during weather emergencies. The company has, when needed, summoned hundreds of workers from other states to help with repairs and tree trimming.

Pepco weathered Irene without serious public relations damage by having workers already in town maintaining power lines. As a result, the utility succeeded in restoring power within 24 hours to 140,000 of the 220,000 affected customers. Fewer homes served by Pepco in the District and Maryland suburbs lost power compared with homes served by neighboring power companies.

Crane said Exelon would be able to marshal even more forces to deal with storm response, noting that the company had drawn from its own employees and contractors in Chicago and Baltimore to address a storm in Philadelphia.

Pepco Holdings stock finished Tuesday down at $22.79, a day after shares hit their highest price since September 2008. The company has a market capitalization of about $5.76 billion.

Pepco, formerly the Potomac Electric Power Co., began as a subsidiary of a Washington electric streetcar company, selling its surplus power to other cable car operators. The company sold off the transit part of the business under the Public Utility Holding Company Act of 1935 and concentrated only on selling power to businesses and residential customers.