The battle over drug testing for private, state and municipal workers increasingly is shifting from federal courts to the states, where several legislatures and a supreme court have set narrower testing guidelines than those sanctioned by federal courts or proposed by the Reagan administration for federal employes.

Almost one-third of the nation's 500 largest companies now do drug tests, mostly with job applicants and suspected drug abusers. The U.S. Chamber of Commerce says more than half of the companies expect to have such a program by the end of the year. Few use random tests, although the trade group takes the position that companies should be free to do so.

Of the dozen state legislatures grappling with the issue this spring, two -- Montana and Vermont -- enacted laws that ban testing most workers for drug use without at least "reasonable suspicion." Connecticut Gov. William A. O'Neill (D) said he will sign a similar bill that cleared the legislature last week. In a fourth state, Iowa Gov. Terry E. Branstad (R) signed a bill this month that sets the more rigorous standard of "probable cause."

Those laws generally place fewer restrictions on testing job applicants than on testing employes. All require testing by state-approved laboratories, written company policies on use of the tests and verification of positive results by approved methods. They also require confidentiality and establish procedures for assuring that no one tampers with specimens. The Vermont and Iowa laws also prohibit the firing of employes who successfully complete rehabilitation programs.

Maine Gov. John R. McKernan Jr. (R) recently vetoed a similar bill that he generally had supported because, unlike new laws in other states, it did not allow random testing of workers in positions deemed to affect public safety.

Only Utah has authorized broad drug testing.

In some states, including Minnesota, there are two or more pending bills whose effects would differ greatly. As many legislatures near the end of their spring sessions, it is unclear how they will act.

"If a state as a matter of state law wants to restrict drug testing, it can," said Richard K. Willard, the U.S. assistant attorney general who has been riding herd on the president's policy of encouraging widespread random testing. "I think it's a wrong decision, but they certainly have the power to do that."

The state actions have no effect on federal workers, nor does an executive order by President Reagan mandating random tests for many federal workers affect other public and private workers.

A House-passed bill would ban funding for drug testing of federal employes; a Senate-passed bill would allow testing only after the administration certifies that specified safety, quality-control and employe-rights standards have been met. A compromise has not been worked out.

Meanwhile, state courts are expected to get more challenges of random drug tests under state constitutions after a ruling last week by the New York State Court of Appeals, the first state supreme court to take up the issue. It held unanimously that random tests to identify illegal drug use by probationary teachers in a Long Island school district violated guarantees against unreasonable search and seizure in the state and U.S. constitutions.

The New York Civil Liberties Union had raised the state constitutional issue in a friend-of-the court brief. Norman Siegel, the group's executive director, said the strategy probably will be attempted in many other state courts, especially by other affiliates of the American Civil Liberties Union. The U.S. Justice Department had filed a brief in support of the random tests.

Most state constitutions replicate the guarantees in the Bill of Rights -- often copying the language -- and seven states have explicit privacy guarantees in their constitutions not found in the federal document.

The ACLU's hope, Siegel said, is that state supreme courts will be more likely than the U.S. Supreme Court to see random drug tests as unconstitutional intrusions and that the state courts will base their rulings on the state constitutions.

State supreme courts are reversed less frequently by the U.S. Supreme Court for their readings of their own constitutions than for their interpretations of the U.S. Constitution.

With an evident eye to that fact, a three-judge New Jersey appellate court panel recently overturned a random drug-testing program for Newark police officers and said it was doing so solely on state constitutional grounds.

"While we like to believe that the United States Supreme Court would reach the same result as a matter of federal constitutional law," the opinion said, "we offer no such prediction."

In Boston, a federal judge sent back to state court a challenge of a random testing program for city police officers. Willard said neither side's position has prevailed at any level in that case, in which the Justice Department also filed a brief backing the random tests.

U.S. appeals courts have upheld random tests for U.S. customs workers, Iowa prison guards and New Jersey parimutuel personnel. Willard said the state-level challenges as well as state and federal legislative efforts have been made because federal courts generally have not found drug testing unconstitutional.

Mark Rothstein, a professor at the University of Houston Law Center, said that, absent public-safety and similar considerations in those three fields, "both the state and federal courts are pretty reluctant to uphold drug testing on a random basis on anything less than a reasonable suspicion."

Mark A. de Bernardo, a special counsel for the U.S. Chamber of Commerce, said that while businesses generally have not had time to react to state-level developments, most of those developments would not affect the testing that companies are doing, often in conjunction with a treatment program.

"Most employers that do it, do it for job applicants or when there is a drug incident," de Bernardo said. "The average employer is not interested in finding out whether the bag boy at the supermarket had marijuana on Saturday night but whether someone who is strung out is working on the brakes of your car or handling explosives or switching rail lines."

But de Bernardo said more and more employers are testing all those who are offered jobs, regardless of the position. "There is more drug testing in the workplace than there was six months ago, and there will be more six months from now than there is today," he said. "The drug abuse problem has captured the attention of chief executive officers around the country. And the question is: Is there a role for employers to play?"