President Reagan, saying that AIDS is "surreptitiously spreading throughout our population," yesterday called for a significant expansion in routine AIDS virus testing for prisoners, immigrants, applicants for marriage licenses and those seeking treatment for drug abuse or sexually transmitted diseases.

"AIDS affects all of us," Reagan said last night at a fund-raising dinner sponsored by the American Foundation for AIDS Research. "Just as most individuals don't know they carry the virus, no one knows to what extent the virus has infected our society . . . . It is time we knew exactly what we were facing. And that is why I support routine testing."

Reagan, in his first major speech on AIDS, said he has asked the Justice Department to plan for testing all federal prisoners and has ordered a review of "other federal responsibilities," including determining whether to begin testing patients at Veterans Administration hospitals.

Reagan, who received some boos along with applause, called on the states to institute routine testing for marriage license applicants, inmates in state and local jails, and those seeking treatment for drug abuse or sexually transmitted diseases.

"Not only will testing give us more information on which to make decisions, but in the case of marriage licenses it might prevent at least some babies from being born with AIDS," he said.

"America faces a disease that is fatal and spreading," the president said. "This calls for urgency, not panic."

Reagan's speech came on the eve of the Third International Conference on AIDS, which opens here today. {Details on Page A4.}

Although Reagan endorsed "routine" rather than "mandatory" testing -- a practice that most public health officials, including Surgeon General C. Everett Koop, have said would drive the disease underground by discouraging people at risk from seeking medical advice and treatment -- a White House official said that the president strongly supports mandatory testing.

"Routine testing can be mandatory or people can be given the right to opt out," said Gary Bauer, Reagan's domestic policy adviser. "In all federal areas {immigrants, federal prisoners}, the president is talking about mandatory testing."

"At the state level he is saying 'Look, we need routine testing,' but this way states would have the option of letting people applying for marriage licenses or being treated for drug abuse have the right to refuse in advance," Bauer said.

However, Bauer said that people might not be told the test is being done. "It would be like going into the hospital now; they draw blood but don't tell you everything they're testing for."

Public health officials and civil liberties groups, who have urged the administration to reject mandatory testing in favor of expanded voluntary, anonymous testing programs, expressed dismay at the speech.

"I find it very distressing that the administration has reached a conclusion that is contrary to the best public health thinking in this country," said Kristine Gebbie, chairman of the AIDS Task Force for the Association of State and Territorial Health Officers. "I am very concerned that they're using 'routine' to mean 'mandatory' and I really object to the lack of informed consent."

"What this means is that public health people will have to reexplain the same arguments all over again, rather than directing their energy into productive channels like education," said Gebbie, Oregon's chief health officer.

"This is a typical Reagan administration response," said Jeffrey N. Levi, executive director of the National Gay and Lesbian Task Force. "Instead of showing leadership and demonstrating how this epidemic can really be contained, he's following the simple path."

This year nearly a dozen state legislatures have rejected bills that would have required premarital testing on the grounds that it would be ineffective and expensive. Public health experts have argued that because most AIDS cases have occurred among homosexual men and intravenous drug users who have low marriage rates, mass screening would be expensive and ineffective. Money allocated for mass testing, they argue, would be better spent on education programs.

Reagan's speech caps an intense debate within the administration over testing. The debate intensified in April when the Centers for Disease Control submitted a report that rejected mandatory testing and called for new laws to ensure the confidentiality of test results and protect those found to be infected against discrimination. The report was based on a February conference of 800 health specialists in Atlanta.

Reagan said that "we must not allow those with the AIDS virus to suffer discrimination," but did not mention new legislation.

His remarks on education -- which he said should focus primarily on "values" rather than on methods of preventing AIDS such as using condoms -- appear to signal a defeat for Koop, who has advocated explicit AIDS education that includes instruction about condoms.