Hamaas Abdul Khaalis testified yesterday that he and 11 other Hanafi Muslims on trial for murder and kidnaping were following the will of Allah-not specific plans of their own-when they took 149 hostages at three Washington buildings last March.

"Allah was the plan," he said in answer to questions from both prosecution and defense attorneys. "Allah directs everything. Allah directs the whole world."

Khaalis was the only witness that the defense called after some six weeks of prosecution evidence. Except for two tapes of recorded telephone calls, his testimony ended the defense's case.Harry T. Alexander, the former judge who is representing Khaalis, said Monday that the defense would be lengthy. The case is expected to go to the jury next week.

Khaalis told the D.C. Superior Court jury that he and his men were "servants of God" who had undertaken a "holy war" because "the Zionist Jews had plotted the death of my children through those letters used by the Black Muslims."

This was a reference to the murder of seven members of Khaalis' family by Black Muslims in 1973. Khaalis said he and other Elijah Muhammad, the late leader of the Black Muslims, was "Zionist Jew."

And so, Khaalis said, he and six others took over the international headquarters of Binai Birth, the Jewish service organization, at 1640 Rhode island Ave. N.W. Three others took the Islamic Center at 2551 Massachusetts Ave. N.W., in the heart of "Embassy Row," and two took the District Building at 14th and E Streets N.W.

At the District Building, Maurice Williams, 24, a radio reporter, was killed by a blast of shotgun fire.

Was he aware that what he doing was against the law? asked Assistant U.S. Attorney Martin J. Linsky, one of the prosecutors.

"Sir, I have lost my identity," the 55-year-old Khaalis replied. "My faith and my country come first. What the Zionists are doing exceeds anything that was being done. It had to be done."

But the crucial question was whether Khaalis had planned all three takeovers with his codefendants.

It was the crucial question for the prosecution, because all 12 Hanafis have been charged with a conspiracy to force officials to turn over to them for revenge the five Black Muslims convicted of the 1973 murders.

It is under the conspiracy theory - each party to an agreement to carry out an illegal act is responsible for anything done by any other party in furtherance of its ends - that all 12 are charged with murder.

It was the crucial question for several defense attorneys because they are asserting that the takeover of the District Building was done by two Hanafis on their own and not as part of any plot. If they can convince the jury of this, then the murder charges against their clients will fall.

The clients of these attorneys - men who were at the B'nai B'rith building and the Islamic Center - have strenuously resisted any effort to free them of the crimes with which all are charged. They have gone so far as to threaten the lawyers with "pestilence" and injury to their families if they persisted.

This led to an unusual and dramatic courtroom situation revolving around who would ask this question - the prosecution or the defense. Apparently because of orders from officials high in the U.S. Attorney's Office, prosecutor Linsky closed his cross-examination without asking it.

The reported reasoning behind the orders was that Khaalis would claim responsibility for all three takeovers without being asked about it directly. This would have left it to the defense attorneys to try to break this story to support the theory that the District Building incidents were separate from those at the other buildings.

The defense would have had this right because such expected testimony would have been against their clients on the conspiracy and murder charges.

By not asking whether Khaalis had planned all three takeovers, Linsky left the prosecution with this tactical disadvantage: The defense could argue that the government had failed to ask the question because it was afraid the answer would undercut its case.

When Linsky announced that he had no further questions of Khaalis, Judge Nicholas S. Nunzio called a recess. There were hurried conferences among prosecution and defense lawyers. When court reconvened. Linsky saidhe did have further questions.

"Was it Allah who told you to go into the B'nai B'rith?" Linsky asked.

"It is Allah who lets you speak now." said Khaalis. "Yes."

"Didn't you discuss with (Abdul) Muzikir and (Abdul) Nuh going to the District Building?"

"There was no discussion," Khaalis said.

There was "no discussion" about any of the sieges, Khaalis said. The men "moved according to their own conscience . . . Through the years since the killing of my family, all Hanafis have known exactly what is what."

When Khaalis said in answer to another question that there was "no difference between the takeover of the Islamic Center and the District Building," there was a flurry of objections from the defense. Judge Nunzio banged his gavel and said:

"Let me suggest this. I won't tolerate screaming into those microphones. This is a search for the truth. I'm admonishing you in public to watch yourselves. I suggest that you calm down and behave yourselves."

He then ordered another recess.

Prior to Linsky's second round of cross-examination, several defense attorneys were prepared to forgo cross-examination of Khaalis and argue that the government had failed to ask what one called "the $64 question."

But in light of the later situation three defense attorney - John Mercer, John Treanor and Francis Smith - succeeded in eliciting answers from Khaalis that were the same as those he gave Linsky.

The net effect of these exchanges was this: The government will argue that Khaalis claim that his men acted without specific orders is incredible. The defense will argue that the government has failed to prove a conspiracy that includes the District Building takeover and the murder.

Treanor, the court-appointed attorney for Abdul Razzaaq, 23, also known as Nelson McQueen Jr. and as Norman Lee, one of those accused of having been at the Bnai B'rith building, then put on tapes of two telephone conversations Khaalis had during the takeovers. The conversations - with Max Robinson of WTOP-TV and Mrs. Khadyja Khaalis - were among a number that we taped under court order.

The purpose of the first was to show that the recollection of one government witness about the time that certain events occurred at the District Building was faulty.

The purpose of the second was to show that Khadyja Khaalis expressed surprise when her husband told her that Abdul Nuh, 28, also known as Mark E. Gibson, and Abdul Muzikir, 22, also known as Marquette Anthony Hall, had taken over the District Building.

Treanor said it was unlikely that Mrs. Khaalis would sound surprised at the news if the District Building had figured in a conspiracy.