Ace Ltd., the Swiss-based global insurer with significant operations in Philadelphia, has agreed to buy Allianz S.E.'s Fireman's Fund unit serving wealthy clients - a move that will allow Ace to expand its insurance of luxury homes, yachts, and art collections as Allianz narrows its focus in the United States.

Ace, which has offices on Walnut Street in Old City, will pay $365 million in the deal, expected to be completed in second quarter 2015, the company said last week in a statement.

Chief executive officer Evan Greenberg takes over a brand that was established in San Francisco more than 150 years ago and that survived the city's 1906 earthquake.

Insurance for the wealthy has wider profit margins than other types of personal coverage, according to Paul Newsome, an analyst at Sandler O'Neill & Partners L.P.

This is "a business where service matters a lot," Newsome said in an interview before the deal was announced. "And the customer base is willing to pay for that."

Ace, Chubb Corp., and American International Group Inc. are among insurers that have been investing in coverage for the rich. Allianz, Europe's largest insurer, has been losing market share in the U.S. residential market, with policy sales falling about 17 percent from 2008 to 2013, according to data from A.M. Best compiled by Bloomberg.

Greenberg has been expanding Ace through acquisitions around the world. The insurer has bought businesses in Brazil, Thailand, and Mexico in recent years.

"The addition of the personal-lines business of Fireman's Fund will reinforce and advance Ace's position as a premier provider of insurance to the high net worth market," Greenberg said in the statement.

The benefit in taking over Fireman's Fund is "buying the customer base and the opportunity to put them onto your platform and add a little bit of scale," Mark Dwelle, an analyst at RBC Capital Markets, said before the deal was announced.

Shares of Ace rose 16 cents Friday to $114.70, extending its gain for the year to about 10.8 percent.

Allianz has been focusing its U.S. insurance operations on business clients. On Sept. 17, the same day the company announced it was considering "strategic options" for Fireman's Fund, the firm said it was transferring the unit's commercial property-casualty operations into the Allianz brand. Five years earlier, the insurer moved its marine lines under the Allianz name.

Allianz will use proceeds from the sale to help restructure the Fireman's Fund's commercial property and casualty business, the company said in a statement.

The insurer previously said that it would wind down some lines of environmental, workers' compensation, and construction-defect coverage through an operation called San Francisco Re.

Allianz bought Novato, Calif.-based Fireman's Fund in 1991 for more than $3 billion in cash in a push to expand sales in the United States. The German insurer had to inject $750 million into the unit in September 2002 to cover asbestos-related claims.