When the U.S. Treasury injected $245 billion in taxpayer money into U.S. banks at the height of the financial crisis, the biggest fear was that a very large bank would fail, triggering massive losses — and serious political blowback.

But the toughest job for Treasury officials managing the Troubled Asset Relief Program, or TARP, has been coaxing paybacks out of dozens of smaller institutions. With the stroke of a pen, Pacific Capital Bancorp’s controlling shareholders Gerald Ford and Carl Webb cured one of the biggest TARP headaches when they inked a $46-per-share sale to Union Bank’s parent company. When it closes later this fall, taxpayers will collect more than $160 million in cash in return for an 11 percent stake — roughly 90 cents on the dollar for its $180 million investment.

A Treasury spokesman declined to speak on the record but did not argue with my analysis that Uncle Sam won’t quibble over the 60 percent premium being paid to shareholders based on Pacific Capital’s pre-announcement stock price. At the national level, the bank portion of TARP has crossed into the black, collecting about $259 billion in repayments, including dividends and interest. So any new cash just runs up the score.

Things did not look that great just a couple of years ago, when Pacific Capital was reeling under the weight of a sagging loan portfolio and Ford Financial Fund came knocking with a $500 million capital infusion that heavily diluted shareholders and raised questions about when the government might expect to cash in its chips without booking a big loss.

The Ford investment came after a number of banks, including Union, Wells Fargo and U.S. Bank, kicked the tires but indicated they had limited appetites for working through a mountain of problem loans. With a handful of whiz kids totting portable computers and spreadsheets, the Ford team did what others were not ready to do — it went through every single loan and marked them to market.

The Ford team’s analysis that $500 million would do the trick was accurate and important. It gave the bank a chance for a rare do-over and enabled the Central Coast region to weather the recession with a systemically important financial institution largely intact.

When I spoke to him shortly after the sale was announced, Ford Fund partner Carl Webb said the region’s resilience came as a pleasant surprise. When he was initially approached by Union, Ford said his initial answer was that the $5.8-billion asset Pacific Capital was not for sale.

“If they were interested in buying a company that was not for sale, they had to make a compelling offer. The offer had to address … assets such as our deferred income taxes and our excess mark-to-market valuation — in other words, the write-up of our loan portfolio,” he said.

Watching the Santa Barbara Bank & Trust name fade into banking history will be sad, partly because it had become an aspirational brand that got even the smallest account holder dreaming about retirement to a villa in Montecito.

What Webb clearly saw in his calculations about the future value of Pacific Capital, and what Union also seems to have recognized, is that the Central Coast’s sturdy performance in the recession could be the beginning of a permanent change in the area’s economic fortunes.

The Santa Barbara-Ventura-San Luis Obispo region has emerged from the recession as a global tourism destination that’s increasingly attractive to Asia and the Pacific Rim. It has a collection of niche companies — in technology, agribusiness, footwear, software, manufacturing and biotech — that dominate their markets across the globe.

These are attributes of that Union Bank and its Japanese parent, Bank of Tokyo-Mitsubishi UFJ, are well-positioned to capitalize on. With its cross-ownership stake in investment bank Morgan Stanley, the Japanese financial giant can fully service a pharma giant such as Amgen or help Deckers Outdoor Corp., owner of the Ugg brand, finance its far-flung manufacturing and retail network.

With $90 billion in assets and a much bigger footprint, Union can offer Pacific Capital employees more opportunities for advancement and perks such as post-retirement health benefits to keep them in the fold. People close to the transaction said this particular deal came together very quickly. Webb said the negotiations began in earnest in February. Indications are that the board of directors had roughly a week to vote it thumbs up or thumbs down.

The history of banking over the past few decades is that regional institutions that prove they can survive a tough downturn become very attractive acquisition targets as things turn around. And for savvy acquirers, getting your brand into a new territory can prove extremely profitable over time. It takes commitment, patience, luck and good timing.

Union Bank is paying a premium, but it is getting a valuable property at the beginning of an economic upswing. Ford Financial Fund gets a mountain of cash and the opportunity to apply its recession-tested “SBB&T architecture” to another transaction. And in Washington, D.C., another piece of the TARP repayment puzzle suddenly has fallen into place.