* Piraeus signs deal to buy all 3 Cypriot banks in Greece
* Deal will make it Greece's second-largest bank by assets
* Greece's bank bailout fund to finance the acquisition
By George Georgiopoulos, Lefteris Papadimas and Laura Noonan
ATHENS, March 26 (Reuters) - Greece's Piraeus Bank agreed to buy the operations of stricken Cypriot banks in Greece for 524 million euros, the lender said on Tuesday, in a deal hastily cobbled together to protect the Greek banking sector from the island's debt crisis.
The deal, funded by Greece's bank bailout fund HFSF, means 312 local branches of the three Cypriot banks will reopen on Wednesday after being shut since March 19 as Cyprus scrambled to strike a bailout deal to prevent an economic meltdown.
The transfer of the branches, which represent about a tenth of Greece's banking market, was part of Cyprus's international bailout deal to help shield Greek lenders from the island's crisis and allow Cyprus to shrink its bloated banking sector.
Piraeus beat out rival Alpha Bank to acquire the Greek operations of Bank of Cyprus , Cyprus Popular Bank and Hellenic Bank.
"Customer deposits with the Greek branches of Bank of Cyprus, Cyprus Popular Bank (CPB) and Hellenic Bank are not subject to any bank levy or haircut that has been agreed in Cyprus," Piraeus said.
The deal will make Piraeus Greece's second-largest bank with combined assets of 95 billion euros, overtaking current number two Alpha Bank, and a network of 1,660 branches and 24,000 employees. It will have deposits of 50 billion euros and net loans of 74 billion, meaning a loans-to-deposits ratio of 120 percent.
A bank source with direct knowledge of the deal said the enlarged Piraeus would have too many branches and could achieve synergies by closing as many as 500 over the next three years.
"The message is yes there are going to be branch closures, that will clearly affect headcount, but headcount will be rationalized in a socially responsible manner," the source said.
Piraeus, which was advised by Barclays, Deutsche Bank and Lazard on the deal, said its ratio of non-performing loans will rise to 26 percent from 21 percent after the branch takeover.
Greek banks including Piraeus will themselves be recapitalised to shore up their solvency ratios. Most of the cash injection will be provided by a state bank bailout fund - the Hellenic Financial Stability Fund (HFSF).
Piraeus's capital needs have been estimated by Greece's central bank at 7.3 billion euros. The 524 million euros for the Cypriot acquisitions will be supplied by the HFSF in exchange for shares, an official at the fund told Reuters.
The deal will increase the group's market share in deposits to 27 percent from 19 percent and its share of loans to 28 from 18 percent.
Piraeus has already taken over the healthy part of state lender ATEbank and French lender Societe Generale's Greek unit Geniki as part of a wave of consolidation in the sector to cope with the debt crisis and a deep recession.
The group is also in talks to also acquire the Greek unit of Portugal's biggest bank Millennium BCP.
"The transaction represents another important step towards the restructuring of the Greek banking system in which Piraeus has participated from the very beginning as a core pillar," the bank said.
Piraeus shares, which had rallied 20 percent on Friday when it was picked as a buyer by Greece's bank bailout fund, were down 1.7 percent on Tuesday.