NEW YORK (Reuters) - A federal appeals court in New York said Friday the Federal Housing Finance Agency could proceed with its lawsuit against UBS AG (>> UBS AG) over mortgage losses at Fannie Mae (>> Federal National Mortgage Association) and Freddie Mac (>> Federal Home Loan Mortgage Corp).

Rejecting UBS' bid to dismiss the case, the 2nd U.S. Circuit Court of Appeals said the agency had standing to sue and did not wait too long to bring its case, having sued within three years after it became the conservator for the mortgage financiers.

The decision is a victory for the FHFA, which has been suing 17 banks and lenders to recoup losses that Fannie Mae and Freddie Mac suffered after buying roughly $200 billion of mortgage securities.

Friday's decision upholds a May 2012 ruling by U.S. District Judge Denise Cote in Manhattan, and its reasoning will apply in the 14 other FHFA lawsuits she handles, plus a 15th lawsuit pending in Connecticut. The other FHFA case is in California.

The agency had sued UBS for fraud and misrepresentation in its underwriting and sale of $6.4 billion of residential mortgage-backed securities that Fannie Mae and Freddie Mac bought from September 2005 through August 2007.

UBS spokeswoman Karina Byrne did not immediately respond to requests for comment.

FHFA General Counsel Alfred Pollard said he was pleased with the decision.

The Swiss bank had argued the FHFA's July 2011 lawsuit was filed too late because it was nearly four years after the last securities at issue had been bought.

But Circuit Judge Denny Chin wrote for a unanimous three-judge 2nd Circuit panel that the Housing and Economic Recovery Act, a 2008 law designed to stabilize Fannie Mae, Freddie Mac and other government-sponsored agencies, allowed the case to go ahead.

"Congress obviously realized that it would take time for this new agency to mobilize and to consider whether it wished to bring any claims and, if so, where and how," Chin wrote.

The FHFA became the conservator of Fannie Mae and Freddie Mac after federal regulators seized the mortgage financiers on September 7, 2008.

Among the other banks whose cases are overseen by Cote are Barclays Plc (>> Barclays PLC), Bank of America Corp , Citigroup Inc (>> Citigroup Inc.), Deutsche Bank AG (>> Deutsche Bank AG), Goldman Sachs Group Inc (>> Goldman Sachs Group, Inc.) and JPMorgan Chase & Co (>> JPMorgan Chase & Co.).

In January, FHFA settled one lawsuit against General Electric Co (>> General Electric Company).

The case is Federal Housing Finance Agency v. UBS Americas Inc et al, 2nd Circuit Court of Appeals, No. 12-3207.

(Reporting by Bernard Vaughan and Jonathan Stempel; Editing by Gerald E. McCormick and Bernadette Baum)

By Bernard Vaughan