The protracted war between Doral Financial (DRL) and the government of Puerto Rico over a massive tax settlement has turned decisively in Doral’s favor, with a court ruling in Doral’s favor awarding the beleaguered bank the full $229 million at stake.

The decision sent Doral’s shares soaring in intraday trading in anticipation of the massive injection of cash the bank expects to receive as a result of the ruling. The $229 million, which is to be paid out in installments spread over five years, provides much needed relief for a bank that has battled insolvency fears and prior fraud allegations.

In 2006 Doral was forced to settle with the SEC over allegations the lender cooked the books and grossly overstated earnings. The bank entered into what amounted to an Alford plea, neither admitting nor denying wrongdoing while admitting they could be found guilty, and paid out a $25 million civil penalty.

Doral believed they had overpaid taxes from this period and thus were due a hefty refund from their home government. Puerto Rico provisionally agreed before balking and trying to annul the repayment.

Doral’s history of impropriety was cited in the Puerto Rican government’s opposition to paying out the tax settlement. The island nation’s treasury claimed that an earlier agreement in 2012 to provide Doral with the funds was spurred by fraudulent misstatements. San Juan Superior Court Judge Laureana Pérez Pérez disagreed, and awarded Doral the full amount of the refund.

This was the second victory in a row for Doral. Shares of the company previously saw a 70 percent intraday spike after the initial court ruling in favor of the Puerto Rican government was overturned by an appellate court, opening up the possibility for Doral’s eventual court victory.

The tax refund will help shore up Doral’s Tier 1 capital to bring it into line with the requirements places on all banks following the 2008 financial meltdown. Through either ignorance or outright carelessness Doral had misstated earnings and had allowed the company to fall into what the FDIC calls “significantly undercapitalized.”

The Puerto Rican government plans to appeal, but for the time being, Doral is soaring. The Small-Cap Star stock gained more than 30 percent in early trading action.