* BPI gains sharply on bond holdings
* Pays back some govt loans (Adds background, detail)
LISBON Jan 30 Banco BPI, Portugal's third-largest listed bank, swung to a higher-than-expected net profit in 2012 from a year-ago loss as the lender booked strong capital gains on government bonds.
The profit of 249 million euros ($337.88 million) sharply beat expectations and came after a loss of 285 million euros in 2011, the year Portugal was forced to seek a bailout from the European Union and IMF.
But the bank said it made a capital gain of 170 million euros on government bonds last year, aided by a sharp improvement in the euro zone debt crisis, especially after the European Central Bank announced it was ready to buy government bonds.
BPI said it also gained 122 million euros from the purchase of its own debt last year.
The result allowed the bank to pay back 200 million euros in so-called contingent convertible bonds to the government, leaving the government with 1 billion euros remaining. Those bonds were issued as part of the 12 billion euros of funds set aside in Portugal's bailout to help the banking sector.
The bank said core Tier 1 capital ratio reached 15 percent at the end of 2012, easily exceeding the Bank of Portugal's requirement of a minimum 9 percent ratio.
Confidence surrounding Portugal has been sharply boosted in the past few months and its bonds have been some of the strongest performers in Europe in the past year. Ten-year government bond yields stood at around 18 percent a year ago and currently trade around 6 percent.
($1 = 0.7370 euros) (Reporting By Axel Bugge; editing by Keiron Henderson)