MARCY GORDONWASHINGTON (AP) ¿ Guaranty Bank became the second-largest U.S. 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 U.S. 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 U.S. bank. The bank failure, the 10th largest in U.S. history, is expected to cost the deposit insurance fund an estimated $3 billion. The FDIC seized Austin-based Guaranty Bank, with about $13 billion in assets and $12 billion in deposits, and on Friday sold all of its deposits and $12 billion of its assets to BBVA Compass, the U.S. division of Banco Bilbao Vizcaya Argentaria SA, Spain's second-largest bank. In addition, the FDIC agreed to share losses with BBVA on about $11 billion 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 Monday in a regulatory filing that the company was critically short of capital and didn't believe it could stay in business.