On three occasions in 1976, Maryland prison inmates James T. Merritt tried to find out from federal authorities when he would have to begin serving an outstanding 1-to-3-year federal prison term for embezzlement. Each time, he was told by a person in the U.S. marshal's office that there was no intention of making him go to jail for that crime.

Merritt, 31 took the federal government at its word. Over the next three years, he won release from prison to go to college, where he made the dean's list; became a minister counseling troubled youths; entered Bible college; married his sweetheart and became a father.

Four months ago, there was a knock on his door. Federal marshals had come for him and took him swiftly to the Allenwood federal prison to begin serving the term that he had been told he could ignore. He has been there since.

Merritt, dressed in a white turtleneck sweater, was in federal court here yesterday trying to convince a judge that he should be released. About 30 of his supporters and church coworkers gathered in the courtroom to watch the proceedings.

U.S. District Judge Harold H. Greene ordered Merritt back to Allenwood at the end of the hearing, but said he would rule in two or three days on Merritt's request.

Greene asked the government at one point in the hearing how many times it expected a potential prisoner to attempt to turn himself in to authorities after he had been told he wasn't wanted.

"It sounds like a Catch-22 situation," Greene said at one point after Merritt's social worker testified he had "no doubt in my mind" Merritt would be freed on the Maryland charges except for the federal warrant.

"That's what it is," the social worker replied.

As recounted in court testimony yesterday, Merritt's tale is clearly one of a mix-up in the complicated world of consecutive state and federal prison terms where some agency forgot to notify another agency about his release.

"My client is stuck in the middle," Merritt's attorney, Dale A. Cooter, told Judge Greene. "There's something wrong with a system that lets a guy out to get his affairs in order, and then at the whim of whomever. . . pulls him back and tells him to report to Allenwood."

The government's position was simple. Prosecutors agreed that the case before Judge Greene had its "Unfortunate circumstances," but they said that the law is the law and Merritt owed the federal government the 1-to-3-year prison term that he is now serving.

"There is no question that mistakes were made, 'Assistant U.S. Attorney R. Dennis Osterman told the judge.

"But the federal sentence has never been served."

Merritt testified yesterday about his four convictions, which began in 1968 consecutive 10-year sentence for sellingdrugs.

After he had received those 20 years of prison terms in 1972, he was indicted on a federal charge of embezzlement growing out of a plot to steal money while a D.C. bank teller. it was for that crime that he received the 1-to-3-year prison term.

Meanwhile, Merritt had been admitted to a special and somewhat controlversial maryland prison program that in effect suspended his 20-year state prison terms and gave him an indefinite sentence.

His adjustment to that new program was excellent, his prison social worker testified yesterday. He first won daytime furloughs to attend catonsville (Md.) Community College, and was then told that he would be considered for further release from prison if he could determine the status of his outstanding federal term.

Three times in 1976, according to Merritt's testimony -- which was not disputed by the government -- he contacted the U.S. marshal's office in Baltimore and was told there -- once by U.S. Marshal John spurrier -- that the Baltimore marshal's office wasn't interested in arresting him on the federal charge unless someone specifically asked that he be picked up.

After Merritt's talks with the federal marshals, he was ultimately sent from the Patuxent, Md., prison program to a halfway house in baltimore and then allowed to live with his family. He still was technically considered in the Patuxent program however, his social worker testified yesterday, because he regularly attended therapy sessions.

"As a result of recommitting my life to Christ in the institution," Merritt said, he began working with troubled youths, entered Washington Bible college in Lanham, Md., and formed what he called a "christian construction company" called Sunnyside Builders, which employed other exconvicts.

He testified yesterday that since he has been imprisoned his wife has given to their first child and has taken over the duties of caring for a sister-in-law who is paralyzed as a result of a brain opeation.

Merritt was arrested by federal marshals on June 1 after the sentencing judge -- who has since died -- asked the U.S. Attorney's office here to determine the status of the sentence.

Merritt conceded that he never went again to the U.S. marshal's office in Baltimore once he was allowed to live on his own by the Maryland prison system.