A federal judge cleared the way yesterday for Metro to build a controversial section of the rail system's long-stalled Green Line from Anacostia to a Prince George's County terminus near Branch Avenue.

The order, issued by Judge Norman P. Ramsey in U.S. District Court in Baltimore, ended a court battle that blocked construction of the Green Line's southeastern branch for nearly three years.

Metro General Manager Carmen E. Turner hailed the ruling, saying that the transit authority "is now legally free to proceed with design, real estate acquisition and construction" of the six-mile rail extension.

The ruling stemmed from a decision last month by Metro's board of directors to endorse the Branch Avenue alignment. The board's unanimous vote marked a reversal of a 1980 decision to extend the line to a terminus near Rosecroft Raceway.

In a one-sentence order, Ramsey said he had "dissolved" a March 1982 injunction that had barred construction of the Green Line's southeastern branch. He also dismissed the lawsuit that had led to the injunction.

Ellis J. Koch, a lawyer for advocates of the Rosecroft terminus, could not be reached for comment. Court officials said, however, that Koch had not raised any objection to Ramsey's action.

David H. Cox, a lawyer for supporters of the Branch Avenue plan, said that Ramsey's order "represents the end of a very successful effort to rectify past mistakes." In their lawsuit, the Branch Avenue advocates had argued that Metro erred in adopting the 1980 Rosecroft alignment -- a contention endorsed by Ramsey.

Officials have previously said that the Metro board's recent endorsement of the Branch Avenue route may eventually face a court challenge by Rosecroft advocates. Cox contended, however, that any legal challenge now would be "an uphill battle" because Metro has gone "to great lengths" to avoid errors in its recent actions.

Prospects also are uncertain because no federal funds have been set aside to extend the Green Line beyond Anacostia. Construction of the section between Anacostia and southern Prince George's has been estimated at $483 million.

Moreover, federal officials recently have expressed concern about the costs of the proposed route. They have cited estimates by Metro officials indicating that construction of the Branch Avenue alignment would cost $132 million more than the Rosecroft proposal.

Nevertheless, Metro officials have said they plan to seek a further authorization of federal funds from Congress to complete the route, which is scheduled to open in 1997.

The extension is to include stations at Congress Heights in Southeast Washington and at Southern Avenue on the D.C.-Maryland border. Three stations would be built in Prince George's, at Naylor Road, Suitland and Branch Avenue.

In his March 1982 order, Ramsey had held that Metro failed to comply with legal requirements for conducting public hearings on its proposed routes. The transit authority recently held new hearings in the District and Prince George's on the issue.