BALTIMORE, DEC. 21 -- A federal judge today refused to bar traditional prayers from the University of Maryland's midyear graduation ceremonies, rejecting for the moment an atheist student's contention that the prayers violate the Constitution's separation of church and state doctrine.

Acting just 18 hours before the commencement exercises set for 9:30 a.m. Tuesday in College Park, U.S. District Judge Norman P. Ramsey said the student, Rockville senior Matthew J. Barry, 23, would not likely suffer "irreparable harm" -- one of the criteria for granting a last-minute prayer ban -- and suggested he could "stand out in the hall" during the prayers if he finds them objectionable.

"If he's really so upset, he can come late and leave early," Ramsey said in denying Barry's request for a preliminary injunction. Ramsey noted that the prayers consist of a brief invocation and benediction at the beginning and end of the ceremonies at the university's Cole Field House.

In a combative exchange, American Civil Liberties Union attorney Arthur B. Spitzer argued that such a choice is similar to a public elementary school student leaving the classroom during prayers, an option now banned by the Supreme Court.

"The First Amendment simply doesn't allow the government to pray," said Spitzer.

Susan Goering, another ACLU lawyer representing Barry, said the organization would not appeal Ramsey's ruling because there was so little time before Tuesday's commencement. Instead, she said, it would prepare for a fuller hearing on the issue before Ramsey this winter in hopes of stopping similar prayers planned for the university's next graduation exercises in May 1988.

Tuesday's scheduled commencement involving about 2,200 students includes an invocation by Dr. Neil Petty, a Mormon elder, and a benediction by the Rev. Elizabeth Platz, a Lutheran minister.

In its suit filed Dec. 3, the ACLU contended the invocation and benediction amounted to "state-sponsored delivery of prayers" and thus should not be allowed at public, tax-supported institutions such as the University of Maryland.

But James J. Mingle, an assistant attorney general representing the university, argued today that the prayers, which have been recited at commencements for more than 100 years, are "acknowledgements" rather than "endorsements" of religion and thus permissible under Supreme Court rulings.

Also, Mingle said, while courts have drawn strict lines against prayer in elementary schools because of compulsory attendance and peer pressure among youngsters, a more relaxed standard can be allowed in the relatively mature and permissive atmosphere of a university.

Mingle noted that the Rev. Timothy S. Healy, president of Georgetown University and a Roman Catholic priest, is the commencement speaker at the Maryland graduation and is scheduled to receive an honorary degree, yet the university "is not endorsing Roman Catholicism because of this choice."

ACLU attorneys said they were not contesting Healy's involvement in the ceremonies.

After today's 80-minute hearing, Judge Ramsey said there was an "ocean of controversy" surrounding the prayer issue and he did not want to "rush to judgment" by ruling in favor of the ACLU without a fuller inquiry. "This case has not matured . . . with everyone getting a crack at it," he said.

A hearing, possibly including testimony by students and separation of church and state experts, will likely be scheduled early next year.