King Hussein's dream of turning his close political alliance with Iraq into an economic bonanza has foundered as the war-burdened Baghdad government has run out of cash.

Bogged down in the third year of a costly war with Iran--and with no end in sight--Iraq has begun defaulting on multimillion-dollar payments due overextended Jordanian businessmen lured by Baghdad's now much reduced oil revenues, banking sources said.

They said the king has yet to bail out the businessmen, whom he had encouraged to invest heavily when he inaugurated a political alliance with President Saddam Hussein's government in Baghdad in 1978.

Deprived of all but 750,000 barrels a day in oil exports by the closure of its Persian Gulf export terminals and the pipeline across hostile Syria, Iraq has been living on aid from Saudi Arabia, Kuwait and other gulf oil producers since the early months of the war which began in September 1980.

But while Jordanian investment in Iraq has foundered, and once-generous Iraqi aid to many Third World countries has been cut, the Iraqis have continued to provide about $300 million a year in aid to Jordan in recognition of King Hussein's solid political support throughout the war. Those funds were part of an overall annual $1.25 billion pledged Jordan at the Arab League summit meeting held in Baghdad in November 1981.

"The king's unstinting political support ensures that the Iraqis want to pay," one financial source remarked, "but the question is--can they?"

With official encouragement, Jordanian exports to Iraq jumped from $39 million in 1979 to $84 million in 1980 and $189 million in 1981. The first six months of last year also showed a continuing upward surge when those exports totaled $126 million.

But in the absence of official statistics for the last half of 1982, banking sources already had predicted difficulties ahead when no new Iraqi contracts were signed throughout all last year.

Specialists said a plastics company and at least one large civil engineering and construction company were in "heavy trouble." In the last few years Jordanians had made handsome profits from the transit trade passing through the Red Sea port of Aqaba and overland to Iraq and by providing vegetables, poultry, eggs and imported household goods to the Iraqi market.

The world's number two oil exporter at the outbreak of the gulf war, Iraq is dependent on its so-called strategic pipeline across Turkey to the Mediterranean for its much reduced foreign exchange earnings. Even were Iraqi oil to fetch the Organization of Petroleum Exporting Countries' official $34-a-barrel price, its income would come to less than a third of the several billion dollars a month required to fuel its war economy, according to specialists.

Various gulf countries have kicked in to make up the difference to the tune of more than $20 billion since the war began.

Symptomatic of Iraq's financial problems is the $500 million Eurodollar loan Baghdad is trying to float. Jordan's own cash flow problems are reflected by a similar $200 million deal being put together which incorporates $80 million previously borrowed on the Eurodollar market.

The setback in economic relations with Iraq was only the latest in a series of negative developments plaguing King Hussein's once heady plans to harness Arab oil profits to develop the desert land he has ruled for three decades.

Dependent on foreign aid for just over half the government budget and 80 percent of the ambitious five-year development plan ending in 1985, Jordan has had to slash $345 million, or more than a third, from its development investment plans for 1983.

The $10 billion five-year plan depended for success on steady foreign aid contributions and ever-increasing remittances from the 300,000 Jordanians working in the oil-producing countries of the gulf.

Now these twin assumptions are being undermined and voices are being heard that the entire Middle East may have entered an era of slower growth with the apparent end of the oil bonanza of the past decade.

The oil glut shows no sign of abating. Saudi oil revenues have plunged by more than 50 percent during the past 18 months. Kuwait's largesse is likely to be cut back because of the government's responsibility in reimbursing at least some of the tens of billions of dollars lost in the Kuwait stock exchange collapse.

Remittances, which jumped 30 percent between 1981 and 1982 and accounted for more than $1 billion, are leveling off. Overseas Jordanians have funneled money into Europe and the United States, attracted by higher interest rates and a revived New York stock market. Also deterring investment here are the war jitters caused by Israel's invasion of Lebanon and Israeli Defense Minister Ariel Sharon's reiterated suggestions that the monarchy be overthrown and Jordan turned into a Palestinian homeland.

Gone are the heady days of the Baghdad summit when the oil-rich Arab countries promised Jordan--and other nations facing Israel--generous 10-year subsidies.

Even when Libya and Algeria dropped out, Kuwait and Saudi Arabia made up the difference until last year. Then, because of falling oil revenues, they reneged on the two nations' shares.

Jordanian planners still count automatically on the yearly Iraqi stipend. The downfall of Saddam Hussein clearly would create major political and economic problems for the king.

"It is very difficult to get Jordanian businessmen to echo the king's view of a long-term relationship with Iraq," one source said. But the Jordanian business community has proved quick to adapt to changing political winds.

The king's alliance with Iraq followed a four-year honeymoon with Syria during which Jordanians were encouraged to invest in joint ventures. Some have survived the chill in relations between Amman and Damascus.

Still, the impressive 9 percent average growth in real gross national product between 1974 and 1980 slipped to 7.5 percent in 1981 and 6 percent in 1982. Specialists think Jordan will be lucky to do as well this year.

Traditional exports such as fertilizers and phosphates are encountering soft prices because of the worldwide recession. Buoying Jordan is a long record of prudent financial and economic management, and government and commercial bank reserves totaling nearly $2 billion.