As the first of the illegal Haitian refugees were released from detention yesterday, the Justice Department remained firm in its stand that it may have lost that battle, but, as Associate Attorney General Rudolph W. Giuliani said recently, it plans to win the war.

Giuliani, who has responsibility for immigration, said in a recent interview, "This administration will firmly enforce the law. The day of just coming into this country and getting in whether you have a right to be here or not is over."

Following the court order that released the Haitians, the Justice Department enacted rules to detain future illegal aliens.

"With the unemployment that we have, with our own cultural and economic problems, we have to enforce the immigration law," Guliani said. "We allow more people into our society than any other country in the world."

Giuliani said the department had lost its case only on the technicality that it failed to comply with formal rule-making procedures--including publication in the Federal Register of a rule change--when it decided a year ago to detain illegals, a policy that was dropped in 1954 for budgetary reasons.

But Giuliani said Haitians had lost the major part of the case: the charge that the government had detained them because they are black.

U.S. District Court Judge Eugene P. Spellman, who ordered their release, found that the policy was not racist: "The detention policy was not directed at them because they were black and/or Haitian, but because they were excludable aliens."

Ira Kurzban, chief lawyer for the Haitians, disputed that yesterday. "We think we clearly proved a case of discrimination," he said. A cross-appeal is being filed on that basis.

Kurzban also said he would file another suit against the government if future policy tends to affect blacks disproportionately.

Giuliani said he is furious about the racism charges.

"It's not a choice of the government to hold black people, white people, yellow people in detention," he said. ". . . This was an evenhanded policy to deal with a national emergency that we inherited. I think we've done a good job turning it around."

He said that much of the policy is set at the State Department.

"Each one . . . has to be decided upon the basis of an evaluation of . . . the country from whence they came," he said. "Otherwise, anybody could come into the U.S. . . . Most people who flee from the Soviet Union claim political asylum because they either were persecuted in their home country or, if they were returned, they would be singled out for oppressive treatment. That's why we have asylum."

Only five or six Haitians have won asylum this year, but Giuliani said they generally don't have good cases.

"There's no civil strife going on in Haiti that I know of. Haiti may be poorer than some of the other Latin American countries . . . but it is not a situation of tremendous political foment," Giuliani said.

". . . They are . . . coming for sympathetic reasons," Giuliani continued. "They're poor. However, I fear that if you open the political asylum process to those with only an economic claim, you're going to swallow up political asylum--because two thirds of the world would have a valid economic claim to come to this country."

However, in a 1980 decision on the Haitian refugees, Federal District Judge James Lawrence King in Miami reached a different conclusion. He found evidence presented by Kurzban to be "shocking and brutal, populated by the ghosts of individual Haitians, including those who have been returned from the United States, who have been beaten, tortured and left to die in Haitian prisons."

But Giuliani said Haiti had assured the U.S. that the returnees would not be harmed.

As the detention policy resumed, the Immigration and Naturalization Service was accused of violating the Haitians' rights by restricting access to lawyers, forcing them to sign forms they couldn't understand and then summarily deporting them.

Giuliani conceded problems: "Forty people having a mass hearing with one interpreter for all was not a fair hearing . . . but being able to delay an asylum process for a year, two years, three years, is not fair to the American people."

The administration is pushing a major immigration reform bill--which has widespread congressional support--to provide amnesty to most illegal aliens now here, penalize employers who hire illegals and speed up deportation procedures. If the bill fails this year, Giuliani said he was ready to begin lobbying when Congress resumes in January.