A New York appeals court yesterday lifted an unprecedented, post-midnight injunction that temporarily barred St. Martin's Press from distributing a book by a former agent of Mossad, the Israeli intelligence service, that portrays Mossad as "dangerously out of control" and often working against U.S. foreign policy.

The book by Victor Ostrovsky, a Canadian with dual Israeli citizenship who said he worked for Mossad from 1983 to 1985, became an overnight cause celebre after the Israeli government charged that publication would damage its national security and endanger the lives of Israeli agents.

Legal experts said Manhattan Supreme Court Justice Michael J. Dontzin's ruling, at 1 a.m. Wednesday at his Fifth Avenue home, was all the more remarkable because St. Martin's had already shipped 17,000 copies to bookstores across the country and mailed review copies to newspapers.

The Israeli government obtained a similar injunction that remains in force in Canada, where Ostrovsky, 40, is in hiding.

In a telephone interview yesterday, Ostrovsky said he is afraid of being kidnapped and forcibly taken to Israel but plans to return to his home near Ottawa today because "enough is enough. I'm not going to hide under a rock any more.

"If they grab me, it's up to the Canadian government and Israel whether or not I'm forced to go back. I can't hide like this any more," he said.

On Sept. 5, Ostrovsky said, two men he described as "ranking Mossad agents" appeared at his home and warned that, for his "own safety," he should try to stop publication of the book. Since then, he said, he has lived like a fugitive, sleeping at a different place each night. "It's scary," he said.

Ostrovsky said he takes seriously the danger of being abducted and returned to Israel because Israeli newspapers have been comparing him to Mordechai Vanunu, an Israeli nuclear technician kidnapped in Rome in 1986, apparently by Mossad agents, and taken to Israel after providing information on an Israeli nuclear weapons installation to London's Sunday Times. Convicted of treason after a secret trial, Vanunu was sentenced in 1988 to 18 years in prison.

"They {the Mossad} work by a different set of rules," Ostrovsky said.

The book's most sensational charge is that Mossad had detailed information about terrorist plans to use a Mercedes truck for an attack in Lebanon before the 1983 suicide bombing in which such a truck was used to kill 241 U.S. troops.

But Mossad gave U.S. authorities only a "vague" general warning because, according to Ostrovsky, the head of Mossad said that "we're not there to protect Americans. They're a big country."

Ostrovsky and his co-author, Ottawa columnist Claire Hoy, also allege that Mossad withheld information on whereabouts of American hostages, facilitated drug trafficking and recruited cadres of Jews in other countries. The book says Mossad has a secret division called Al, for "above" or "on top," that operated mostly in the United States and referred to New York and Washington as "playground."

But it is not clear how Ostrovsky, who spent most of his time at Mossad as a trainee, could have had firsthand knowledge of such activities, some of which predate his service there. He says in the book that he learned about the operations from his access to Mossad computers.

The temporary injunction against "By Way of Deception: The Making and Unmaking of a Mossad Officer" marked the first time that a foreign government has blocked, even briefly, distribution of published material in the United States, legal specialists said. Such prior restraints are far more common in Canada, where two newspapers, the Toronto Star and Ottawa Citizen, are under court order not to write about the book.

"I don't think the government of Israel really believes anyone will be endangered by this," said Roy Gainsburg, president of St. Martin's. "I think the government of Israel thinks they're going to be embarrassed by this. To ban a book because it's embarrassing is just something that is not done in this country. That's what the First Amendment is all about."

Attorney Bruce Sanford, a First Amendment specialist here, called the injunction "remarkable" and "a bit like closing the proverbial barn door after 17,000 horses are out of it."

The state appeals court said that the Israeli government had "failed to substantiate . . . its claim that the safety of Israeli intelligence agents is endangered" and that an injunction would be "ineffective" because the book has been sent to 1,500 bookstores and major media outlets.

Gainsburg called the ruling "a victory for a free press."

But Jonathan J. Lerner, a New York attorney representing Israel, said that "the Israeli government did exactly what the CIA does" in requiring employees not to publish information about their activities without government approval. If a CIA agent "broke his promise to the CIA and wanted to publish a book in Jerusalem, we'd expect that court to honor our agreement," he said.

Lerner said that, even as a low-level employee, Ostrovsky could have had "access" to important secrets. He said the author "prefers his credibility to the lives of others."

Lerner said Israel, while weighing an appeal of the ruling, is pursuing litigation to attach the book's profits because Ostrovsky's information "is in effect owned by the Israeli government, and others ought not to profit from that information."

The Israeli Embassy here said in a statement that "the mere mention of names, whether correct or incorrect, endangers the lives of many people. Anyone mentioned in the book, and his or her family, becomes a potential target for hostility." The embassy accused Ostrovsky of "a disregard for human life and of his pledge of allegiance toward his country. In our opinion, his actions are motivated by a desire to profit financially . . . . "

In recent days, official Israeli sources and the Israeli media have portrayed Ostrovsky as a low-level Mossad trainee with a checkered personal history who was fired by the intelligence agency and had no way of knowing about some of the sensational events he describes.

According to Israeli accounts, Ostrovsky is a former military policeman and Navy major who got into trouble for trying to run a private vegetable service out of his home while in the Navy. He was later involved in allegedly pirating foreign video cassettes, ran up large debts, was threatened with death at one point and became a police informer, according to these accounts.

Official sources in Jerusalem said the government decided to try to block the book to avoid establishing a precedent for other former Mossad agents. One informed source said the Mossad was particularly angered by the genuine details revealed in the book, such as internal names for Mossad units and coding procedures for information.

Ostrovsky said in the interview that he has been the object of an "orchestrated smear campaign" by the Mossad and Israeli newspapers. "My friends {in Mossad} are saying that I wore high leather boots and was, you know, weird. Well, if that's true, they really know how to pick their people, don't they?"

He said Israeli newspapers have carried stories quoting the tenant of an apartment that he is said to own in Israel as saying he found a box containing secret Mossad documents. "The only trouble is, I don't even have an apartment in Israel," Ostrovsky said.

Lou Clancy, the Toronto Star's deputy managing editor, said, "To me, the issue is not so much the contents of the book but the fact that the Israeli government feels it should be suppressed. If the book is not credible, what is the concern?"

Angel Guerra, spokesman for Stoddart Publishing Co., the book's Canadian publisher, said Ostrovsky was so stunned when the Israeli government identified him as a former Mossad agent in legal papers that he blurted out, "Oh my God, they've laid a claim to me."

"I've had Israeli journalists tell me his life isn't worth a dime," Guerra said.

Even within the government of Israeli Prime Minister Yitzhak Shamir, there is concern that the episode was mishandled in a way that simply calls more attention to the book. "We thought we had a best-seller," Guerra said. "What we have is a mega-seller, thanks to Yitzhak Shamir."

Some Washington-area bookstores said they have not received the Ostrovsky book, while others said their five to 10 copies had sold almost immediately.

Ostrovsky described himself as a "left-of-center, ardent Zionist" who believes that Israel has lost its ideals and sense of purpose. He said the Ontario court order barred him from discussing the book or the secrecy agreement that he is said to have signed.

Recalling the nighttime visit from the two Mossad agents, Ostrovsky said: "They said they wanted me to help them stop the book. Money was no object. Whatever expenses I had or whatever profits I expected, they would take care of . . . . They said it was for my own good, that I was endangering myself."

Claiborne reported from Toronto. Staff writer Charles R. Babcock in Washington and correspondent Jackson Diehl in Jersualem contributed to this report.