Facing military threats from some of their neighbors and hostile propaganda from others, Kenya and Sudan are becoming friends.

Although Sudan still relies heavily on its traditional northern patron, Egypt, for moral and military support, a 16-man delegation from Khartoum visited Nairobi last week and signed an agreement designed to lead to close economic and political cooperation.

Only a few years ago, Sudan, a member of the Arab League, was Kenya's most remote neighbor in every respect, but now the two countries plan to translate ideological agreement into a 600-mile road that will make the Kenyan port of Mombasa the gateway to the outside world for the now-isolated but potentially rich southern Sudan.

If the talk of developing southern Sudan into the breadbasket of the Arab world becomes reality, Kenya will benefit tremendously because Nairobi-based engineering, construction and marketing companies are bound to win many contracts.

In signing the joint communique that resulted from almost a week of discussions, the Sudanese foreign minister, Mansour Khalid, said, "Our minds were as one on all the issues we discussed."

Khalid then thanked Kenya for allowing the Palestine Liberation Organization to open a Nairobi office, a political statement that is destined to result in other Arab dividends for Kenya.

Kenya's recent shift from an equivocal stance on the Middle East to a firmly pro-Arab policy has pleased the Sudanese.

The Kenyan foreign minister, Munyua Waiyaki, emphasized the political harmony between the two countries, adding: "We are uncomfortable with foreign interference in Africa, especially on her Horn."

Making what sounded like a reference to the Soviet Union and perhaps Cuba, Waiyaki added, "We have decided to fight together against uninvited foreign intrusion.

Just five weeks ago Sudan expelled about 90 Soviet military advisers and ordered the Soviet Union to reduce its embassy staff in Khartoum.

Kenya and Sudan stand alone in this part of the world in pursuing an unswerving anti-Communist foreign policy and both have recently begun receiving American military assistance.

In the short run, Kenya stands to profit most because of potential exports of agricultural and manufactured goods to Sudan.

Between 1972 and 1976 the value of Kenyan exports to Sudan jumped from $1.5 million to $10.5 million, while Sudan, which previously had exported nothing to Kenya, sold $340,000 worth of goods here last year.

The countries have now extended most-favored-nation status to each other, and Kenyan exports to Sudan should continue to grow.

With the death of the three-nation East African Community, Kenya no longer enjoys those privileges with Tanzania and Uganda, traditionally its closest trading partners, but these countries have long been at odds with Kenya for political reasons.

Sudan, with a population of 16 million and Arab-donated petrodollars to spend, could turn into the largest consumer of Kenyan goods once the road is built.

In addition, Sudan's influence with the oil-producing Arab states could help Kenya improve its position in other lucrative markets. Arabs who are investing in Sudan, such as Adnan Khasoggi, are dropping into Kenya for a look, and they generally like what they see.

It is no coincidence that Afro-Arab cooperation was near the top of the list of 16 points in the joint communique.

Now that both countries are facing armed conflicts on their borders - Sudan on its Ethiopian frontier, Kenya on its border with Somalia - each is reassured to have a neighbor with whom relations are growing friendlier.