A federal judge in Alexandria refused yesterday to stop the Army from contracting with a McLean firm to do maintenance work at Fort Belvoir, an action that a union has said will cost 500 government workers their jobs.

U.S. District Court Judge James C. Cacheris ruled his court lacked jurisdiction over a union lawsuit against the Army. Henry LaHaie, a Justice Department lawyer who represented the Army, said Congress had ruled that such disputes must be resolved by the Federal Labor Relations Authority instead of the courts.

Robert R. Greene, an official with the Fort Belvoir Chapter of the American Federation of Government Employees, which filed the suit, said the union would take its case to the authority on Monday. If the authority finds that there are reasonable grounds to believe the Army has engaged in unfair labor practices, it can file a complaint and seek an injunction that would block the contract in a federal court.

Local 1052 of the government workers' union sought the injunction in December after the Army announced that it had signed a one-year, $5.5 million contract with the Dynalectron Corp. to provide maintenance work for the Army base in Fairfax County, beginning this month.

The union, which says it represents 2,000 Army civilian employes, contended the move would eliminate 531 jobs and result in the transfer of 273 other employes, some to lower-paying jobs. It asked the Alexandria court to rescind the Army's reduction-in-force and job-change notices.

"We're not through with this by any means," the union's Greene said yesterday. "We feel we're going to be able to stop it."

LaHaie, the Army's attorney, said that no permanent civilian employe of the Army had lost his job as a result of the contract, a move that the Army has said will save $10.5 million over the next five years.

He said most employes who had been transferred were given similar posts, and that none of them had suffered a pay cut. He said that the part-time employes were not within the union's jurisdiction.