Guaranty Bank became the second-largest US bank to fail this year after the Texas lender was shut down by regulators and most of its operations sold at a loss of billions of dollars for the US government to a major Spanish bank. The transaction approved by the Federal Deposit Insurance Corp. marked the first time a foreign bank has bought a failed US bank. The bank failure, the 10th largest in US history, is expected to cost the deposit insurance fund an estimated $3 billion. The FDIC seized Austin-based Guaranty Bank, with about $13b. in assets and $12b. in deposits, and on Friday sold all of its deposits and $12b. of its assets to BBVA Compass, the US division of Banco Bilbao Vizcaya Argentaria SA, Spain's second-largest bank. In addition, the FDIC agreed to share losses with BBVA on about $11b. of Guaranty Bank's loans and other assets. Guaranty Bank, with 162 branches in Texas and California, saw its investments in real-estate lending and mortgage-backed securities bought from other banks sour and had been teetering near collapse for weeks. Its parent, Guaranty Financial Group Inc., reaffirmed last Monday in a regulatory filing that the company was critically short of capital and did not believe it could stay in business. In April, the federal Office of Thrift Supervision said the company had engaged in "unsafe and unsound" banking practices and ordered it to raise fresh capital, find a buyer or face a takeover by the government. Guaranty's failure, along with those of three small banks in Georgia and Alabama on Friday, brought to 81 the number of US bank failures this year amid rising loan defaults spurred by tumbling home prices and spiking unemployment. That is the highest number in a year since 1992 at the height of the savings and loan crisis; it compares with 25 last year and three in 2007. Two weeks ago, the FDIC seized Colonial Bank, a big lender in real-estate development, and sold its $20b. in deposits, 346 branches in five states and about $22b. of its assets to BB&T Corp. It was the biggest bank failure so far this year, and the sixth-largest in US history. Birmingham, Alabama-based BBVA Compass, with 600 branches from Florida to California, said its acquisition of Guaranty creates the 15th-largest commercial bank in the US, with about $49b. in deposits.