PNC Financial Services Group Inc has agreed to buy Royal Bank of Canada's U.S. retail bank operations for $3.45 billion in cash and stock, two people familiar with the matter said on Sunday.

For the stock component of the deal, PNC has the option to deliver up to $1 billion in stock, one of the sources said.

PNC is also buying $165 million worth of credit card portfolios from RBC, the source said.

The deal is expected to close in the first quarter of next year, the source added.

The sources declined to be identified because the deal is not public yet.

RBC, the largest Canadian bank by assets, put its struggling U.S. consumer banking business on the market after failing for years to wring profits from the operations acquired nearly a decade ago. JPMorgan Chase & Co is advising RBC on the sale.

Bank of America is advising PNC in the deal.

RBC's U.S. retail bank has lost money for 10 straight quarters and has generally been a drag on earnings since RBC purchased North Carolina-based Centura Bank in 2001 for $2.2 billion ($3.5 billion Canadian at the time).

Representatives for RBC and PNC were not immediately available for comment. JPM and Bank of America declined to comment.

(Reporting by Paritosh Bansal and Soyoung Kim; Editing by Bernard Orr)