In a message from his federal prison cell, the leader of the Hanafi Muslim group that held 149 people hostage in the nation's capital two years ago has urged the Ayatollah Ruhollah Khomeini to free the 49 Americans being held hostage in Iran "to prevent a mockery of our Faith."

Hamaas Abdul Khaalis made his appeal in a letter to the ayatollah that he dictated by telephone to his wife. The message was hand-delivered to Iranian Embassy, where it was telexed to the ayatollah in Iran.

The letter begins "My Dear Brother in Islam," and ends by saying, "I have not been asked by the government to initiate this appeal to you." The U.S. government knows about Khaalis' letter, however, because a copy was also sent to President Carter. The Washington Post has obtained a copy.

In a telephone interview, Khaalis comfirmed the authenticity of the letter. He said the conversation with a Post reporter was his first interview since he was sentenced two years ago.

"My concern is the release of the American citizens that are held there now -- and my concern is also that the Persian people get justice," Khaalis said, speaking calmly and articulately from his prison ward.

"If this is not resolved peacefully, it would be disastrous for both sides, There will be no winner at all. Believe me, I know . . . When I tried to rectify an injustice . . . we have seen that wrath comes down and trouble comes."

Referring to the ayatollah, Khaalis added:

"We are dealing now with a Muslim mind that wants to see that injustices are resolved. From the laws of Islam, I know where he is coming from. But I also know that nothing can be resolved until those hostages are all released."

In his letter to the ayatollah, dated Nov. 17, Khaalis said:

"You know one piece of wood does not make a fire, neither can you pull a hair from the head with one finger. Therefore, I am asking you as one who strives for humility and submissiveness, and as one who has held hostages also, to prevent a mockery of our Faith (Islam) . . .

"The Shah Muhammad Riza Pahlevi; no man, woman or child, be they a tyrant, is worth sacrificing one Muslim's life, when Allah has given you the power to build a new people. Hamaas ask (sic) you, In the Name of Allah, and in All of Allah's Names, Secret and Revealed, to let all of the Hostages go, American or otherwise; this will In the Name of Allah let you be successful as to your Spiritual Objectives . . . Do not let one man stop progress In the Way of Allah."

In a postscript, Khaalis urged Khomeini to free the hostages "In the Name of Allah to unify the Muslims and to show the world that all Mussulmans are highly civilized."

On March 9, 1977, a group of Hanafi Muslims led by Khaalis seized three Washington buildings -- the international headquarters of B'nai B'rith, the Islamic Center, and the District Building. A total of 149 persons was held hostage during the siege, which lasted into the early hours of March 11. A radio reporter was killed and more than a dozen persons were wounded by gunshots and stabbings.

Khaalis, now 57, was sentenced to 41 to 123 years in prison on charges of armed kidnaping, murder, assault with intent to kill, and conspiracy.

He is currently held in a federal prison. As part of government's witness protection program, government officials asked The Washington Post to withhold the location of the prison.

His wife lives in Washington.

In the telephone interview, Khaalis said he did not want to talk about the details of his own episode. But he conceded that the experience of holding hostages, and seeing death and serious injury come to some, taught a grim lesson -- that Iranian students and the ayatollah cannot win once blood is shed.

He said his own experience led him to conclude that peaceful intentions of spiritual people can lead to violence and tragedy.

"I didn't slaughter nobody -- and I easily could have," he said. ". . . We are talking about human souls. I never ordered nobody to kill anyone. But it could happen accidentally. Or someone could crack up and go berserk . . . Anything can happen to those people [the hostages] now. It could set off World War III."

"Everyone knows the deeds the shah has done," he said, ". . . even though it was not our blood that the tanks rolled over and it was not our blood that was spilled when the people fired on the crowds at point blank. And everyone knows the role the United States played in Iran. But we have to clear that off the table . . .

"Believe me . . . I know what it is like to find a family slaughtered." Seven members of his family and followers were murdered in 1973. "Also, I know what it is like to walk in and take people [hostage].

"I know what it is like . . . I know it only leads to trouble -- that things can blow up."