* Cypriot ruling party says deal in line with EU demands
* Party says deal could be reached in hours
* Russian finance minister says talks end without result
* ECB says to cut off bank funds without bailout deal by Monday
NICOSIA, March 22 (Reuters) - Cyprus was just hours away from a deal on Friday to raise billions of euros and unlock a bailout from the European Union that could avert financial meltdown and exit from the euro, its ruling party said.
The remarks from the deputy leader came after Moscow had rebuffed requests from Nicosia for assistance to save Cypriot banks in which Russians have billions of euros at risk.
He gave little detail beyond saying Cyprus was close to a compromise that would let parliament reverse its rejection of a rescue package offered by euro zone partners a week ago under which holders of bank deposits would suffer losses.
"There is cautious optimism that in the next few hours we may be able to reach an agreed platform so parliament can approve these specific measures which will be consistent with the approach, the framework and the targets agreed at the last Eurogroup," Averof Neophytou, deputy leader of President Nicos Anastasiades's Democratic Rally, told reporters in the capital.
Germany warned Cyprus it was "playing with fire" but also kept up pressure by saying the euro zone was well able to contain any crisis - sticking to a threat to cut Cyprus off.
With the clock running down to a Monday deadline set by the European Central Bank when it will sever essential cash flows to Cypriot banks if no bailout programme is agreed, Cyprus took a first step toward financial consolidation by arranging for the takeover of big Greek units of its banks by a Greek competitor.
Shares in Piraeus Bank in Athens shot up 20 percent before officials confirmed Piraeus would take control of the Greek units of Bank of Cyprus and Cyprus Popular Bank, two big retail lenders badly burned by exposure to Greece's own troubles.
Euro zone leaders, led by Germany, have offered Cyprus 10 billion euros ($13 billion) on condition it raises 5.8 billion of its own. A plan to fund that by taxing deposits - breaking what had hitherto been a taboo in efforts to stabilise the currency bloc - had led to parliament throwing out the deal.
EU officials criticised Cyprus for insisting on taxing even small savers whose deposits up to 100,000 euros benefit from a state guarantee - a measure Cypriot leaders favoured in order to limit the losses for bigger depositors, many of them Russian and seen as vital to the future viability of the Cypriot economy.
Hopes of favour from Moscow were disappointed on Friday.
Cypriot Finance Minister Michael Sarris left for home after failing to renegotiate a 2.5-billion euro loan from the Russian government, win new financing or lure Russian investors to Cyprus's banks and gas reserves.
The Bank of Cyprus urged the government to go back and make a deal with the EU, under which larger deposits over 100,000 euros, would be taxed. It was preferable, it said, to a collapse of the system and a return to the Cypriot pound which would wipe out assets. "There must be no further delay," the bank said.
EU leaders, notably Germans who face an election in six months, have been reluctant to give up on the bank levy since it protects them from accusations of using European taxpayers money to bail out big Russian investors in Cyprus.
While this had raised concern that it might erode confidence in banks in other, bigger euro zone states, notably Spain and Italy, the leaders of the euro zone have made clear they believe they can contain any damage, even it Cyprus is forced into a bankruptcy that would lead to it abandoning the euro.
German Finance Minister Wolfgang Schaeuble said on Friday that muted reactions to the crisis in financial markets showed the euro zone was able to contain the Cyprus problem.
On the island, lawmakers and banking officials were locked in talks inside parliament. Hundreds of angry Cypriots faced off with riot police outside.
On the table are proposals to nationalise pension funds, pool state assets and split Popular Bank in a desperate effort to satisfy exasperated European allies.
There were persistent rumours of a possible U-turn on the bank levy, targeting only big depositors with over 100,000 in Cypriot banks, many of them foreigners including Russians.
"PLAYING WITH FIRE"
Everything is subject to the approval of Cyprus's lenders at the EU, ECB and International Monetary Fund.
The head of the Eurogroup of euro zone ministers, Dutchman Jeroen Dijsselbloem, said it was focused on keeping Cyprus in the euro zone. Asked whether Cyprus's exit from the euro zone was inevitable, he did not rule it out, however:
"All kinds of scenarios are possible and the scenarios we're focusing on are to come to a joint solution in which Cyprus is saved but in which the banking sector continues in a smaller but healthier form."
Germany had rejected a proposal to nationalise pension funds and demanded Cyprus take an axe to its banks.
Chancellor Angela Merkel told lawmakers that while she wanted to keep Cyprus in the euro zone, the country must first recognise it had no future as an offshore financial centre for wealthy Russians and Britons, two parliamentarians told Reuters.
Cypriots have been stunned by the pace of the unfolding drama, having elected conservative President Nicos Anastasiades barely a month ago on a mandate to secure a bailout.
Depositors, who have been besieging bank cash machines all week, queued again on Friday to withdraw what they could.
"Our so-called friends and partners sold us out," said Marios Panayides, 65, a protester at the parliament. "They have completely abandoned us on the edge of an abyss."