The more cumbersome way
This works as follows: a bank is split into a good and bad bank. The old shareholders keep the bad bank and, as an incentive to go along with the plan, they get a small portion of the good bank.
The good bank is capitalized by the rescuer (typically the government but not necessarily) and dressed up for the wedding, i. e. for the sale back to new owners. That sale will lead to one of two things: either it generates more money than the capitalization had required or less.
The assets of the bad bank are liquidated in orderly fashion. In all likelihood, the shareholders’ equity will be wiped out in total. Typically, there will be an additional loss for the rescuer because the bad bank’s assets are worth much less than its liabilities.
If the profit on the sale of the new bank exceeds the losses taken on the liquidation of the bad bank (after wiping out shareholders’ equity), then the rescuer has made a profit. Typically, the rescuer will make an overall loss but that loss is typically far less than in a bankruptcy scenario.
The more simple way
The rescuer (typically the government) takes preferred stock in exchange for his recapitalization. The deal is structured in such a way that the rescuer gets a preferred rank over existing shareholders to compensate for the new risk he is taking. If the rescue works successfully and normality returns, the rescuer sells his preferred stock, hopefully at a profit. The stock of the old shareholders is probably worth a lot less than before but at least it is still worth something (and it now has the perspective to increase in value again). This is what the US government did with US banks after the 2008 crisis (and similar to what Warren Buffett did with Goldman).
The Greek and Spanish bank bail-out’s differ from the above practices. The ultimate rescuer is the ESM but it does no invest capital nor does it get preferred stock. Instead, it lends money to national entities in Greece and Spain so that those, in turn, can do the recapitalizations. How they do that is not yet clear to me but I have to assume that they get some form of stock in the rescued banks.
The critical question is the following: will the ESM, as a lender to national intermediaries which bail-out national banks, get as collateral the new bank stock issued? For example: the Hellenic National Stability Fund will put fresh capital into, say, Eurobank and get preferred stock of Eurobank. To finance this, the HNSF will obtain a loan from the ESM. Will the HNSF assign to the ESM its preferred stock in Eurobank as collateral or not?
Prudent banking practice would dictate that it should!