LUXEMBOURG -- European Union finance ministers sought an agreement Friday on how best to downsize or close banks without spreading panic or having to call on taxpayers to bail out ailing lenders.

A meeting of the EU's 27 finance chiefs went into the evening in Luxembourg to decide the order in which investors and creditors would have to pay for bank restructurings. One of the stumbling points is who would be hit hardest: Should losses be limited to banks' shareholders and creditors, or should small companies and ordinary savers holding uninsured deposits worth more than 100,000 euros ($132,000) also be included?

Ministers said they were bracing themselves for midnight negotiations. The EU's top economic official, Commissioner Olli Rehn, said an agreement would be another important step to stabilize the bloc's financial system and establish a so-called banking union.

A banking union will make the supervision and rescue of banks the job of European institutions rather than leaving weaker member states to fend for themselves. It is a key part of the EU leaders' plans to restore financial and economic stability to the region.

"We have a fair chance to concluding the work, and it will be very important to maintain the momentum on the banking union," Rehn said.

One controversial issue was how much leeway member states should be granted in making decisions on winding down banks. Some countries like Britain don't want to be bound by rigid European rules. Other nations warned that too much flexibility would create new imbalances between the bloc's weaker and stronger economies and destroy the project of establishing a single set of rules that creates certainty for investors and restores trust in the financial system.

"It's necessary that we have a joint solution in Europe to ensure that the European single market won't be further fragmented," said Luxembourg's Finance Minister Luc Frieden. "It's about ensuring that people in Europe know ... what happens when a bank is being wound down," he added.

In addition to how much capital a bank must hold, the new European rules would also establish a minimum level of funds -- be it capital, bonds, or deposits -- that banks must have on their books to ensure that there's always enough privately held assets on which losses can be forced, thus shielding taxpayers from the burden of propping up the bank.

Following the 2008-2009 financial crisis, countries like Ireland, Britain or Germany each had to pump dozens of billions of fresh capital into ailing banks to avoid the financial system from collapsing.

Once the finance ministers reach an agreement on the package, they will start negotiating the legislation with the European Parliament. If the ministers fail, the setback could undermine confidence in Europe's ability to repair the financial system.

Europe has already had to deal with the problems involved in restructuring banks this year. Cyprus' government had to seek a rescue loan after it could no longer shoulder the cost of bailing out its banks.

An initial agreement with the island's European creditors and the International Monetary Fund sparked market fears since it exposed small savers with deposits under the 100,000 euro guarantee to losses.

The deal was rapidly overhauled, but holders of large deposits in some banks were forced to take harsh losses.

In the U.S., the Federal Deposit Insurance Corp.'s rules specify that deposits larger than $250,000 might have to take losses in case of bank failures, but Europe still lacks a common rule.

The new rules being discussed Friday will also foresee the establishment of national bank restructuring funds, which will eventually be merged into a European resolution authority, one of three planned parts of Europe's banking union.

Another part will be centralized oversight of big banks anchored at the European Central Bank due to be operational next year. But the discussion on the third section, a jointly guaranteed deposit insurance, is only in its early stages.

"The banking union is built brick by brick," stressed French Finance Minister Pierre Moscovici.

At their meeting, the finance ministers also rubber-stamped a seven-year extension of maturities on the bailout loans for Portugal and Ireland, granting the countries more financial leeway.

On Thursday, the finance ministers of the 17 EU countries that use the euro agreed on broad guidelines on how to use the bloc's permanent bailout fund to inject fresh capital into ailing banks as a means of last resort to keep banks from failing.

Enabling the 500 billion euro ($670 billion) rescue fund to shore up struggling banks directly is another long-promised building brick of the banking union.

Several finance ministers, however, have cautioned that despite a political agreement on the broad strokes for the new ESM mechanism, many details have yet to be hammered out before it can become operational.

"Given the fact that these steps are not exactly taken at lightning speed, the banking union should be up and running just in time to prevent the next crisis but clearly too late to make a difference in the current crisis," said analyst Carsten Brzeski of ING bank.