Most of the largest banks passed their annual stress test, the Federal Reserve revealed in an earlier-than-expected release of the results, after JPMorgan Chase pulled the trigger on announcing its glowing marks and helped lift the stock market.

But the failing grade for Citigroup, the nation's third-largest bank, was a substantial surprise. Going into the tests some analysts felt it had a better chance of a positive surprise than any other financial institution.

The Fed said on Tuesday that 15 of the 19 banks tested could take a financial shock that would see unemployment hit 13 percent and housing prices drop 21 percent.

MetLife, the largest life insurer in the United States, was also among the four financial institutions that failed the exam, which applied worst-case stress scenarios looking out through the end of 2013.

Ally Financial and SunTrust were also at the bottom of the heap.

Among the winners was JPMorgan, which has been agitating for regulators to loosen the handcuffs on the ability of banks to raise dividends and buy back stock.

The Fed uses the annual stress tests to give the markets a window into the health of the U.S. bank industry, and also determine if individual banks are strong enough to reduce their capital buffers.

JPMorgan, in a surprise to markets, announced around 3 p.m. EDT (1900 GMT) that the Fed had given it permission to raise its quarterly dividend by a nickel to 30 cents and buy back as much as $12 billion of stock this year.

The news helped the U.S. stock market post its best day this year.

The Fed had been scheduled to release the test results after markets closed on Thursday. A senior Federal Reserve official told reporters that it came to the Fed's attention Monday evening that there may have been an inadvertent release of some information.

The Fed official, who could not be quoted by name, said JPMorgan's announcement was the result of less-than-perfect communication between the bank and its regulator, and said that nobody at JPMorgan was at fault.

Regarding the outcome of the tests, the Fed official said the capital positions of U.S. banks has improved substantially in the last three years.

The Fed took a tough line with the banks, and in a number of instances, the central bank's estimates of banks' losses under the hypothetical financial shock were larger than the firms' own, the official said.

The Fed faces pressure to be tough enough so that the tests have credibility, but not so tough that the results spook markets.

Overall, we can't complain that these tests weren't rigorous enough and it's good to know that most banks would at least survive another global financial meltdown. Nevertheless, this doesn't mean that the U.S. economy would be unaffected by a meltdown in Europe, said Paul Ashworth, chief U.S. economist at Capital Economics in Toronto.

The Fed released 82 pages of detailed information showing how the 19 banks fared under the hypothetical stress scenario.

The regulator left it to the banks themselves to reveal if they had received permission to boost dividends or buy back stock.

The regulator said Citigroup, Ally Financial and SunTrust fared worst under the hypothetical shock, with Tier 1 common capital ratios of 4.9 percent, 4.4 percent, and 4.8 percent respectively.

MetLife failed the stress tests on the basis of its risk-based capital ratio. At a 6 percent minimum, it was lower than any of the other banks examined.

The bank holding companies that came out top were Bank of New York Mellon with a Tier 1 common capital ratio of 13.1 percent under the hypothetical financial shock, State Street Corp with 12.5 percent and American Express with 10.8 percent.

Wells Fargo was allowed to increase its quarterly cash dividend rate to 22 cents, while U.S. Bancorp got permission for a 56 percent increase in its dividend to 78 cents.

BB&T declared a 4 cent quarterly increase per share for 2012, and American Express and KeyCorp both said they got permission for both a dividend increase and stock repurchase.

PNC said it received no objection for a dividend raise and modest stock repurchase program.

(Reporting by Jonathan Stempel in New York; Additional reporting by David Henry, Rick Rothacker, Ben Berkowitz; Writing by Karey Wutkowski; Editing by Tim Dobbyn)