JERUSALEM, SEPT. 14 -- Israel's government and intelligence community today vehemently attacked a book on the Mossad spy agency published by ex-agent Victor Ostrovsky, but some officials also criticized the Israeli government's last-minute attempts to stop its publication in the United States and Canada through legal action.

The book, "By Way of Deception," sold out its entire first U.S. printing of 50,000 copies late this week after the Israeli government sought an injunction against it in a New York court, Israel Radio reported today. A New York state appellate judge ruled against the Israeli appeal Thursday night.

The book, written by a former Mossad cadet who now lives in Canada, contains a series of sensational allegations, among them that Israel withheld advance information it had obtained about the 1983 truck bombing of the U.S. Marine barracks in East Beirut, and operates a secret division that conducts extensive spying operations in the United States.

After refraining from official comment through most of the week, the government of Prime Minister Yitzhak Shamir today denounced those charges as "lies" and dispatched its spokesmen to attack Ostrovsky as a traitor bent only on avenging himself on the Mossad and Israel.

The book "is an amalgamation of very few facts and a lot of lies and should be given no more credibility than the man himself," said Avi Pazner, a senior adviser to Shamir. Pazner charged that Ostrovsky's "main aims are greed and vengeance" on the Mossad, which officials here maintain fired the former cadet only 14 months after recruiting him in 1984.

Pazner said he did not wish to reply to the bulk of Ostrovsky's account, conceding that some of it was factual. However, he said the government was eager to say that the ex-agent's allegation about the Beirut truck bombing, in which 241 Marines died, was "a complete lie." Pazner also denied that the Mossad had a special unit engaged in spying on the United States.

The government's account was backed by two former chiefs of the Mossad, Isser Harel and Meir Amit, who gave interviews to Israel Radio today and assailed Ostrovsky. Harel, a founding father of the Mossad and its director from 1952 to 1963, called Ostrovsky a liar "who betrayed Israel in the worst way"; Amit, the Mossad chief from 1963 to 1968, said the book "is a joke."

Amit, however, added to a growing current of criticism in Israel about the government's reaction to the book, saying that Israel had only worsened the damage by trying to stop the book in court. "I don't know why we had to give such importance to this affair and inflate the issue by making a formal approach and presenting affidavits as if we were confirming the facts in the book," Amit said.

Pazner said the government felt obligated to act against the book because "it was our duty to try and prevent publication of these lies." He said that now that the government had lost its battle to prevent distribution of the book in the United States -- a case in Canada is still pending -- it was considering what further legal action it might take against the book or Ostrovsky.

Ostrovsky has expressed fear that Israeli agents might try to kill him or abduct him to Israel. But officials here said today it was unlikely the Mossad would launch such an operation against the former agent now that he has gained international attention.

Israel Radio today broadcast an interview with Ostrovsky's American publisher, Roy Gainsburg of St. Martin's Press, who said that "orders are coming in in unbelievable numbers" for the book and that sales could rise as high as 200,000, instead of the 50,000 the publisher originally anticipated. The result, he said, is "just the opposite of what the State of Israel wanted."