Flagstar Bancorp (FBC) agreed to pay up to $133 million to settle Justice Department allegations of underwriting violations on past Federal Housing Administration mortgages.

The troubled Troy, Mich.-based bank will pay an $15 million in the next month. Another $118 million in penalties will be paid when certain events occur and hinge on approval from the Office of the Comptroller of the Currency, the bank's federal regulator.

If Flagstar manages to turn a profit and strengthen its capital position while $266.7 million still owed to the Treasury Department under the Troubled Asset Relief Program is extinguished or no longer counted against its capital status, then the additional payments kick in.

Flagstar would make annual payments of up to $25 million until the balance from the settlement is paid.

The bank will only have to start making these payments within six months of its Tier 1 capital ratio reaching 11%, excluding any remaining TARP balance.

At the end of last year, Flagstar's Tier 1 capital ratio stood at 9.19%.

"Flagstar Bank is one of the leading originators and servicers of FHA insured loans, and we remain committed to continuing in that capacity," CEO Joseph Campanelli said. "This agreement with the Department of Justice allows us to move forward, and to continue to focus on core operations and on serving our customers."

Flagstar reported a loss of $44.9 million in the fourth quarter and still faces a delisting threat from Nasdaq because its stock has traded at less than $1 for too long.

The Department of Housing and Urban Development has settled FHA claims with Bank of America (BAC) and Citigroup (C) since the larger $25 billion servicing settlement was announced in February.