A federal court judge today ordered Virginia to stop interferring with lawyers' visits to troubled Mecklenburg prison, issuing a sharply worded decree that some officials said illustrates a deep division among state officials over prison policies.

District Court Judge Robert R. Merhige dismissed as "public relations gimmickry" claims by the state that the lawyer visits hamper security at the maximum-security prison, scene of recent inmate disturbances and a dramatic escape May 31 by six death row prisoners.

Merhige also rejected as "bordering on the ridiculous" claims by prison officials that a controversial 1983 state agreement with the American Civil Liberties Union on prisoner treatment had endangered security by undermining the authority of guards. The judge accused prison officials of seeking to make the ACLU a "scapegoat" for their problems.

A source close to the case said today that Merhige had warned the state's lawyers last week that they didn't have a good case and urged them to settle the dispute with the ACLU out of court. But the source said that the state corrections department, whose top officials have blamed the ACLU for many of their problems at Mecklenburg, balked.

The same official, noting that Gov. Charles S. Robb and State Attorney General Gerald L. Baliles have avoided criticism of the ACLU, said that the split over prison policies now is so deep that Corrections Director Robert M. Landon's job could be in jeopardy.

Landon confirmed today through a spokesman that in one appearance in August he said the ACLU has $2 million "to do a job on us." Corrections spokesman Wayne Farrar also noted that the director had complained then that the agreement had put a "psychological burden on the staff" and that national prisoner rights groups have forced adoption of "inmate privileges that weaken security" in the country's prisons.

Farrar declined to comment on today's ruling, but did say that the department has done nothing to explain the 18-month-old ACLU agreement to prison staffers. The department is preparing a training plan for the guards, he said.

Robb has said the agreement, which he signed, "simply repeats operational procedures" already in place but not completely followed at the prison. The governor also has maintained that the agreement was not a factor in Mecklenburg's problems and has continually expressed concern that blaming the ACLU was a pointless "emotional" issue that only inflames morale problems at Mecklenburg.

As recently as two weeks ago, Robb made a special visit to Mecklenburg County during which he told the Chase City Chamber of Commerce that "the decree was sound and did not in any way prevent the staff . . . from managing the institution."

Asked about the apparent inconsistency between Landon's statements and those of the governor, George M. Stoddart, Robb's press secretary, said today that the governor "has expressed confidence" in Landon and "that confidence is continuing."

Chan Kendrick, the ACLU's Virginia director, said Landon's critical comments are "totally irresponsible and show a lack of leadership and insensitivity to both legal and moral issues."

Kendrick said his organization is not surprised that the department has failed to explain the agreement. "It has been clear to me and others that there has not been any follow up. . . . I think that is an indictment against the department of corrections in Richmond. It's almost unbelievable to know that no one has bothered to train people on a 20-page settlement."

The ACLU agreement with the state mandates 40 specific changes in prisoner treatment, including mandating humane living conditions, a prohibition against excessive force by guards, and access to lawyers and vistors.

Merhige ordered the state to stop routinely shackling the hands and feet of prisoners during the visits. He also said the state could not arbitrarily impose 90-minute limits on attorneys or allow only one attorney within the prison at a time.

Merhige's order came in response to a suit by attorneys for the ACLU's Washington-based National Prison Project who claimed they were being unfairly kept from inmates.