Salah Khalaf, the No. 2 official in the Palestine Liberation Organization who was murdered Jan. 14, had been for some time a prime source for Western intelligence about Middle East terrorism, Western diplomats here revealed.

They said Khalaf, better known as Abu Iyad, had cooperated with the U.S. Central Intelligence Agency and the intelligence services of Britain, France, Italy and Germany.

''A lot of the things we learned about terrorism in the Middle East we got through Abu Iyad,'' said one diplomat.

The sources said Khalaf`s motive for cooperating with the Western agencies was his belief that they previously had received most of their information about terrorism from Mossad, the Israeli secret service. He feared that Mossad would alter facts to try to discredit the PLO and believed it was important that the PLO present its own information, they said.

The diplomats said PLO Chairman Yasser Arafat was aware of Khalaf`s cooperation with Western intelligence.

Israeli officials have contended that Khalaf was the mastermind of the PLO massacre of Israeli athletes at the Munich Olympic Games in 1972. But more recently Western sources had identified him with the moderate wing of the PLO. Khalaf was shot to death, allegedly by one of his own bodyguards, Hamza Abu Zid. Many Palestinians initially assumed that his killing was the work of Mossad, but diplomats said that was unlikely. They said it bore none of the hallmarks of a Mossad operation.

Other sources have said that Abu Zid was a member of the Abu Nidal faction, a terrorist group that was expelled from the PLO in 1973, and he had infiltrated the PLO. He was reported to have become part of Khalaf`s bodyguard service last July.

Tunisian authorities have given no indication when or whether Abu Zid will be brought to trial. Unconfirmed reports circulating in Tunis say that he has been handed over to the PLO and transferred to San`a, Yemen, to be tried there.

Western diplomats said it still is unclear whether the killing of Khalaf was simply a result of the rivalry between the PLO and the Abu Nidal faction, or whether this faction had been hired by someone else to carry it out.

They said some PLO leaders, including people close to Arafat, have been passing the word that they believe the killing was ordered by Libyan leader Moammar Gadhafi, but it is not clear why they think Gadhafi would have wanted Khalaf dead. The Abu Nidal faction is based in Libya. Its leader, Sabri al-Banna, was sentenced to death by the PLO in absentia in 1973 for killing senior Arafat aides.

Another theory, diplomats said, is that the killing was ordered by Iraqi President Saddam Hussein, whose country previously harbored the Abu Nidal faction.

They noted that Khalaf had tried to restrain Arafat`s enthusiasm for Iraq, and had made statements specifically rejecting linkage between the Palestinian problem and Iraq`s takeover of Kuwait.

Diplomats said Khalaf had accompanied Arafat on several visits to Baghdad after the gulf crisis began last summer, but the Iraqi president eventually had asked Arafat to stop bringing him because it was evident that Khalaf was not sympathetic to the Iraqi position.

''The fact that Arafat agreed to that demand could have been taken by Saddam as a green light to get rid of Abu Iyad,'' one diplomat said.

The sources said a third theory, which they considered hardly credible, was that Arafat himself was involved in the decision to kill Khalaf.

Arafat and Khalaf were two of the three founders of the PLO and were close associates for many years. ''But the atmosphere between them was not good at the end,'' one diplomat said. He said Arafat had been irritated by Khalaf`s views on Iraq, and on a personal level Khalaf had to some extent been challenging Arafat by developing his own contacts with foreign diplomats and journalists.

''Abu Iyad was gaining more and more importance in the PLO,'' the diplomat said. ''But we may never know who decided to have him killed.''