A federal judge, rebuffing a move by Virginia officials, upheld provisions of a labor contract yesterday that require Metro employes to join a union.

In a U.S. District Court ruling, Judge James C. Cacheris said the transit system "has the authorization to enter into a union shop agreement" with Local 689 of the Amalgamated Transit Union. The union represents about 5,600 Metro employes, including more than 700 in Virginia.

The union shop clause, which has been included in Metro's contracts with Local 689 since 1972, requires bus drivers, subway operators, mechanics and other Metro employes to join the union and to pay dues and other union fees.

In June, Virginia sued Metro and the union, contending that compulsory union membership is prohibited under the state's right to work laws. The suit was filed by then-Attorney General Gerald L. Baliles, now governor-elect, and immediately became an campaign issue.

The suit had been brought at the request of Virginia legislators. Wyatt B. Durrette, who was defeated in the governor's race, had charged that Baliles was reluctant to support the right to work laws for fear of losing union support.

Yesterday, David Hathcock, a spokesman for the attorney general's office in Richmond, declined to comment on the ruling, saying that officials have not had sufficient time to review it. Any decision on whether to appeal the ruling will be "up to the governor," Hathcock said. Baliles takes office Jan. 11.

Virginia legislators previously failed to persuade Maryland and District officials to amend the compact regulating the Metro system to reflect the state's right to work laws.

Mark A. Rosen, a lawyer for the union, hailed the ruling as "a clear-cut victory that should discourage any appeal." A spokesman for the Metro system said, "We are pleased with the judge's decision."

Cacheris held that Metro has the right to negotiate labor contracts requiring union membership under a congressionally approved interstate compact that established the transit authority. The compact is a federal law that supersedes state laws, he said.

The judge brushed aside arguments by Virginia officials who contended that the state had been assured, before Metro was created, that transit workers would be governed by the state right to work laws.

"The simple answer to their assertion that they were 'promised' that the Virginia right-to-work statute would remain applicable to Virginia employes . . . is that they should have gotten it in writing," Cacheris said. He cited a federal appeals court ruling in 1983 along with congressional proceedings.