Shaken by its domestic rumblings and distracted by the Soviet invasion of Afghanistan, Saudi Arabia is neglecting a potentially lethal situation in its own backyard -- North Yemen.

Middle East analysts, diplomats and politicians express amazement at Saudi neglect of its once-unquestioned role as protector in North Yemen, where the weak government is negotiating for its own survival with the leftist opposition and the hostile Marxist state of South Yemen.

The steady crumbling of North Yemen's government is also a major concern and embarrassment for the Carter administration, which one year ago rushed into North Yemen with a massive military aid package in its first visible attempt to counter Soviet designs in the strategic Middle East.

Evidence that the $390 million in military aid put forward by Washington did little to shore up the government of President Ali Abdullah Saleh is emerging just as the Carter administration is seeking a $400 million package in emergency military aid to the shaky government of Mohammed Zia ul-Haq in Pakistan in the latest U.S. effort to halt Soviet gains around the Persian Gulf.

Also involved in the American calculation in North Yemen was a desire to prove U.S. determination to the doubting Saudis.

Even then the Saudis were upset by the American inability to keep shah Mohammad Reza Pahlavi on his throne and signs that Iran's new ruler, Ayatollah Ruhollah Khomeini was determined to export revolution to the conservative states of the Arabian Peninsula.

Long before last month's seizure of Mecca's Grand Mosque by hundreds of armed militants, the Saudis had begun a dangerous game in North Yemen, according to analysts.

Over the months, the Saudis, who were supposed to pay for the American materiel which included F5 aircraft, armor and artillery, laid down conditions the North Yemenis found unacceptable. They objected to the Saudis' demands for a tough policy against South Yemen and began negotiating a less onerous arms package with the Soviets.

The Saudis finally stopped all payment. North Yemen concluded an arms deal with Moscow and began negotiating a reconciliation with South Yemen and their own leftist opposition, the National Democratic Front.

Since the Mecca mosque incident, analysts have been struck by the Saudis' apparent lack of concern for the Yemeni situation.

Jordanian officials, for instance, make no secret of their worry over what they feel is Saudi underplaying of both the domestic and Yemeni problems.

The Jordanians are reported aghast at what they consider the Saudi royal family's disarray and failure to grasp the necessity of cleaning up its own backyard. Prince Abdullah, commander of the Saudi National Guard, is said to be an exception.

The Jordanians and other concerned parties also reportedly are convinced that the North Yemeni problem cannot be solved by arms, a polite reference to the Saudi coup-making tradition there.

Some quarters have suggested that only direct U.S. commitment to North Yemen could right a situation with incalculable potential for serious troublemaking. But compared to Iran and Afghanistan, North Yemen is a low-priority worry for the United States.

Yet, the North Yemeni stakes are enormous. As many as a million North Yemenis -- from a nation of about 7 million -- work in Saudi Arabia.

With North Yemen embarked on what one diplomat called a "game of chicken" with the Saudis and the West, the possibility of North Yemeni subversion in the oil-rich Saudi kingdom cannot be dismissed out of hand. Arms are reported to have been smuggled from both North and South Yemen into Saudi Arabia.

Even some kind of arrangement well short of the formal merger between North and South Yemen, which has been under formal discussion for years, would be enough to buffet the now-weakened Saudis and seriously undermine their waning prestige. Anything smacking of merger would, in a veteran analyst's phrase, "drive the United States right up the wall."

Also reportedly worried is Iraq, which since the shah's fall has played a key role in holding the line against both Khomeini's revolutionary proselytism and Soviet encroachments.Iraq played a major role in arranging last winter's cease-fire between the two Yemens and offered North Yemen a $300 million loan in the fall.

But Iraq's credentials there are thought less impressive increasing if only because of Baghdad's increasing anti-Soviet stance and the friendship and cooperation treaty South Yemen concluded with the Kremlin last fall.

Reported South Yemeni efforts to arrange talks with the Saudis have been rebuffed, apparently in part because the Riyadh government is convinced that both Yemens were somehow involved in the Mecca mosque incident.

On the surface, North Yemen seems to reason that the Saudis are too weak to take care of themselves, much less cause trouble in North Yemen.

That may or may not be a good gambit. A veteran diplomat, surveying the wide-scale violence that has followed the assassination of the traditional ruler in North Yemen in 1962, said: "The durability of post-revolutionary regimes there does not give cause to encourage a good night's rest."