In a surprising reversal, last week's losing bidder for 1st Mariner Bank got approval Tuesday to buy it — preserving the city's largest independent bank as a Baltimore-based institution.

The group of investors, a mix of locals and out-of-state investment firms led by Priam Capital of New York, won over creditors with a last-minute offer to sweeten their deal. They agreed to pay about $17.7 million, $3 million of that up front as a deposit.

That bid was roughly $4 million more than the value of competitor National Penn Bank's best offer. When U.S. Bankruptcy Judge David E. Rice reopened the auction, which had been closed Thursday, the Pennsylvania-based bank bowed out — leaving the Priam group as the only bidder.

"We never thought we were out of the fight," said Robert D. Kunisch Jr., a Baltimore banker who is investing with the group and is expected to become 1st Mariner's president and chief operating officer. "Now the future's pretty clear: Attract new clients. We're going to find out if people in Maryland are as passionate as they've said about seeing a local bank."

The bank's parent company, First Mariner Bancorp, filed for bankruptcy-law protection in February after years of trying to rebound from soured residential mortgages. The bank itself wasn't in bankruptcy, but it was auctioned off as the major asset to repay creditors.

The auction was high-finance drama. Hanging in the balance was whether Baltimore would have a bank based here that has at least $1 billion in assets or whether the headquarters would move north to Allentown, Pa. 1st Mariner is the last large Baltimore bank after a long string of acquisitions by out-of-state players.

The Priam-led investor group, organized under the name RKJS Bank, bid $150,000 more than National Penn on Thursday under the complex rules of the auction. But First Mariner named National Penn the winner — later describing its offer as a surer bet.

RKJS officials said in court that they asked to increase their bid but weren't permitted to do so on Thursday. Over the weekend, they offered to raise their payment by $4 million. Then they filed an objection to keep National Penn from being approved as the purchaser.

Despite the new offer, First Mariner witnesses and an attorney for the official committee of unsecured creditors said in court Monday that they considered National Penn the better pick. They argued that the well-capitalized regional bank would be able to win regulatory approval more quickly — allowing the deal to close and creditors to be paid.

Some voiced concerns that RKJS's deal might fall through for lack of timely approval.

"To us, it's a risk," said Jeffrey Gettleman, the creditors' committee attorney, on Monday. "We would rather go with the institution that has a good likelihood of closing."

But the tide had turned by Tuesday morning. RKJS officials, who say they've been talking to regulators for months and are confident approval will come, discussed their efforts with the creditors' committee. And they offered to make a $3 million deposit — money the creditors would keep even if approvals don't come through.

Gettleman said the deposit — and tweaks to the deal's timeline — were key to assuaging creditors' concerns.

RKJS needs approvals from Maryland regulators and the Federal Deposit Insurance Corp. Mark Kaufman, Maryland's commissioner of financial regulation, said his office began reviewing information about RKJS's proposed deal before the auction.

"Now that RKJS is the successful bidder, we intend to work closely with RKJS, First Mariner, and our federal colleagues in order to recapitalize and revitalize the institution as quickly as possible," he said in a statement. "Having a healthy and strong First Mariner Bank is a good thing for the community."

Brian Casey, a banking consultant based in Towson, said he can understand why the creditors' committee thought a regional bank would be better positioned in the regulatory process. But he doesn't expect problems for RKJS, which promised to infuse the bank with $85 million to $100 million in cash to fix its capitalization woes.

"With the amount of expertise of the local investors and the proposed senior management — who are putting money into it — I don't see that as an issue," he said.

First Mariner Bancorp's creditors won't get all their money back. The company's obligations top $60 million. But the $17.7 million price is a "much better" deal for creditors than the initial bid of just under $4.8 million, Gettleman said.

It's a different matter for shareholders. First Mariner warned at the beginning of the bankruptcy process that the people with company stock would likely get nothing.

The bank's largest shareholder is the man who founded it in 1995, Baltimore businessman Edwin F. Hale Sr. He did not return calls seeking comment Tuesday.