Syria and Iraq, citing the great dangers" of the Camp David accords, announced yesterday that they had agreed to shelve their longstanding, often bloody differences and work together toward a "full military union" against Israel.

Their reconciliation, at least on paper, signaled a tightening of Arab ranks as a separate Egyptian-Israeli peace settlement draws ever closer to becoming reality. It also paved the way for an even more formidable display of united opposition to the Camp David results at an Arab summit conference due to open in Baghdad Nov. 2.

But there was no sign, despite the talk of unity that the former rivals in Baghdad and Damascus had agreed on deployment of Iraqi troops on Syria's Golan Heights front with Israel, as Iraq had suggested. Diplomats said such a concrete move would be a provocation to Israel that neither country could afford.

The plans for military cooperation came under a "national charter for joint action" signed at the end of a milestone visit to Baghdad by Syrian President Hafez Assad.

Arab diplomats said that even if no agreements had been announced, the fact that the visit took place at all was significant in view of the recurring hostilities that have split the two neighbors during most of the last dozen years. The sources said the Syrian-Iraqi entente, and the Arab unity it represents, makes it even more difficult for Jordan and Saudi Arabia - two key objects of U.S. efforts to sell the Camp David agreement to the Arabs - to remain noncommittal.

A joint communique issued in Baghdad at the end of Assad's three-day visit said he and Iraqi President Ahmed Hassan Bakr agreed to set up a bilateral committee of foreign and defense ministers and military chiefs of staff to promote military cooperation.

"The committee will draw up a draft joint defense agreement that would serve as the basis for a full military union between the two countries," the communique said.

Bakr hailed the decision as "historic" and a "great and important step."

Assad was more reserved, saying it was only "a first step" toward full cooperation.

His attitude was reflected in the joint communique which, perhaps because its authors were mindful of past reconciliations that have broken down, said: "We are all aware more hard work lies ahead of us and that we have a long way to go."

According to the agreement, the military committee will come under a "joint steering body" which is to meet every three months. Other committees are to deal with political, economic and cultural cooperation. A lengthy preamble to the "national charter" said the rapprochement was the direct result of "the great dangers looming over the Arab nation" because of the Camp David accords.

Some Arab countries, especially Syria, fear that once Israel signs a separate peace with Egypt, it can safely ignore demands for the return of occupied Arab territory and Palestinian statehood, or even launch punitive attacks against them.

Iraqi Information Minister Saad Hammoudi said the idea of a strengthened Syrian front against Israel was aimed at "preventing a Syrian collapse in the face of a sudden preemptive strike."

But diplomats here said any Iraqi soldiers eventually dispatched to Syria under the cooperation agreement would probably amount to no more than a token force to avoid provoking the Israelis.