Portugal has sold the troubled small bank Banif to the local unit of Spain's Santander, the Bank of Portugal announced for 150 million euros ($163 million) but with an injection of 2.3 billion euros in public funds.
"The deal will involve government assistance of 2.3 billion euros to cover future contingencies," the central bank said in a statement.
Socialist Prime Minister Antonio Costa said the deal came at a "very high price for the taxpayer" in a television address shortly after the statement was released.
"But in the current context, this is the best decision in the national interest," he said.
Financial institutions operating in Portugal will provide up to 489 million euros of the injection, via a fund operated by the central bank, while the rest will come directly from the state.
The Portuguese state previously injected 1.1 billion euros into Banif in 2013, retaining a 60.5 percent stake. Banif still owed 825 million euros of that sum.
The European Commission, which opened an inquiry into the deal in July, looked likely to declare the 2013 injection illegal and would have forced Banif to reimburse the money immediately, "which would have created a serious lack of capital" according to the Bank of Portugal's statement.
Banif is among the smallest banks in the country with a market share estimated at just three percent.
But it is the market leader in Madeira and the Azores, with assets of 12.8 billion euros -- equivalent to around seven percent of national GDP, according to the central bank.
Banif will "continue to function normally for its clients, taking on the Santander Totta brand" under which the Spanish lender operates in Portugal, the statement said.