Egypt and Sudan, neighbors whose ties reach back into prehistory, held a unique joint session of their parliaments here today to symbolize the warm and close relations that have put them on the road to unification.

Presidents Anwar Sadat of Egypt and Jaafar Nimeri of Sudan held hands in the traditional Arab fashion as they entered the hall of the People's Assembly here to address the 610 delegates, business-suited Egyptians and turbaned Sudanese who shouted their approval as the two presidents pledged to support each other.

Both expressed the hope that Egypt and Sudan, united by language, religion, history and dependence on the Nile River, would eventually become one country. Both also know, however, that the sands of the Middle East are littered with the bones of hasty, politically motivated national mergers.

"The achieving of grand aspirations," Nimeri said, "needs stamina, men who believe in what they are doing, and patience . . . Let unity not necessarily come at the hands of Jaafar or Anwar today. But let it come tomorrow or later after it is solidly built."

The close ties of Egypt and Sudan have the full approval of Saudi Arabia, which is always concerned about containing radicalism in the Arab world and has promised to support its Red Sea neighbors in their anti-Soviet, conservative policies.

For Sadat, today's session marked another in the series of steps that have drawn him increasingly into African affairs. He said that Egypt and Sudan have evolved a joint strategy to protect the entire region from any attempt at domination and aggression." This was understood to be a warning to the Soviet-backed governments of Libya and Ethiopia.

Sadat and Nimeri both regard those two states as agents to Soviet imperialism in Africa and as threats to their governments. Egypt and Sudan, which a few years ago were in the Soviet orbit themselves and whose armed forces are basically Soviet-equipped, have formed a conservative, Islamic-oriented anti-Communist alliance that has become an increasingly potent force in African politics.

The two countries have been linked by a defense pact since July, 1976, when Sadat helped Nimeri thwart a Libyan-backed coup attempt. As Sadat said today, Egypt and Sudan are "carrying the same sword against the same enemies."

Five years ago, relations between Egypt and Sudan had chilled to the point that Egyptian teachers were being expelled from Khartoum University as their leaders feuded over Middle East policy. Since then, their common hositility to the radical states of the region and their desire to join Saudi Arabia in establishing Arab control over the Red Sea have brought them together.

On paper, the two countries are made for each other, natural allies who can help each other overcome the poverty and backwardness that afflict them both.

Sudan, Africa's largest country with 967,500 square miles, has a population of only about 15 million. It needs Egyptian technical assistance and manpower to help develop its vast agricultural potential as well as the political and military protection offered by Sadat.

Egypt, which has almost 40 million people in a country that is 97 per cent desert, needs access to Sudanese land for its farmers and needs Sudanese food for its urban masses. The Egyptians also want a friendly power in control of the Nile's headwaters, which are life and death to this country.

The Egyptians, however, must overcome a historic Sudanese suspicion that Egypt wants hegemony not partnership. Formerly known as the Anglo-Egyptian Sudan, it was under Egyptian domination for most of the 19th century and half the 20th, achieving full independence only after the Egyptian revolution of 1952.

The Nile has always been the main channel of communication and travel between Egypt and Sudan. The two are only now beginning work on a road link and on direct telecommunications.

They are also unifying and coordinating their national programs in health, labor and social security insurance, and planning to adopt unified textbooks. The six-day parliamentary session will consider these and other plans submitted by a bilateral committee that has been working on them since an agreement on political and economic integration was signed in 1974.