BRUSSELS — The European Union has struck a deal on rules establishing who will pay for bank bailouts in the future without taxpayers having to foot the bill.

The agreement reached by the EU's 27 finance ministers after seven hours of negotiations early Thursday is an important step toward establishing Europe's so-called banking union with the goal of restoring financial and economic stability to the recession-hit bloc.

The set of rules determines the order in which investors and creditors will have to take losses when a bank is restructured or shut down, with a taxpayer-funded bailout being only a limited last resort.

"That's a major shift from the public means, from the taxpayer if you will, back to the financial sector itself which will now become for a very, very large extent responsible for dealing with its own problems," said Dutch Finance Minister Jeroen Dijsselbloem.

The ministers had failed to reach a deal in 19 hours of continuous talks last week, and their latest round of negotiations in Brussels came only hours before a summit of the EU's 27 heads of state and government. At the summit, the EU leaders are expected to take stock of the progress of the bloc's financial and economic policies.

Exactly a year ago, EU leaders pledged to tackle the eurozone's financial crisis by introducing a banking union, which aims to give the supervision and rescue of banks to European institutions rather than leaving weaker member states to fend for themselves.

Since its announcement the project has stalled on many fronts, not the least because richer countries fear they might have to pay for the banking woes of weaker countries. But Thursday's breakthrough gave the endeavor new credibility by establishing clear rules.

"The talks were lengthy, quite difficult and intense," German Finance Minister Schaeuble said. "This is an important step. We make progress step by step" toward completing the banking union, he added.

The EU governments will now start negotiating the legislation with the European Parliament.

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

To avoid that happening again, finance ministers discussed who should contribute in which order and how much to a bank's rescue — a so-called bail-in — so that ordinary taxpayers aren't left with the bill.

"Bail-in is now the rule," stressed Ireland's Finance Minister Michael Noonan, adding the rules put an end to moral hazard by making it clear that banks will suffer before the government might come in to help, if at all. "This is a revolutionary change in the way banks are treated," he added.

The rules foresee for banks' creditors and shareholders to be the first to take losses. But if that isn't enough to prop up the lender, small companies and ordinary savers holding uninsured deposits worth more than 100,000 euros ($132,000) will also take a hit, officials said.

Those forced losses will go as high as 8 percent of a bank's total liabilities, only then would national governments kick in and top it up with a bailout possibly worth another 5 percent of the liabilities.

The negotiations were complicated because some nations feared being bound by overly rigid European rules. Others warned that too much flexibility would create new imbalances between the bloc's weaker and stronger economies and a lack of common rules would destroy certainty for investors and erode trust in the financial system.

But the rules will now apply equally for the 17 EU nations sharing the euro currency and the 10 member states like Britain that have their own currency, said the Netherlands' Dijsselbloem, who also chairs the meetings of eurozone finance ministers.

Europe has already had to deal with serious banking issues this year. Cyprus 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.

The EU's new rules also foresee the establishment of national bank restructuring funds, which would eventually be merged into a European resolution authority, one of the banking union's three pillars.

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