For much of the Middle East, 1977 was the year the oil-financed spending spree ended.

Grandiose development programs were cut back, cabinets were reshuffled and long-term spending goals were reassessed as the region tried to come to grips with the realities of cooled-down world oil market and heated up inflation.

Oil remains the major economic factor in the Middle East. The vast reserves and promising unexplored areas there guarantee that oil will play a controlling role in the region's economy as long as it is needed as a fuel by the industrialized world.

But producers as wealthy as Saudi Arabia, as ambitious as Iran and as underdeveloped as Iraq came to the realization in the past year that oil profits cannot finance all their development dreams.

While their cushion of petroleum profits gave the oil-producing countries flexibility in finding ways to deal with their economic problems, those countries with little or no oil were not so fortunate. For many of them; 1977 was also a year of new economic directions but in some, these attempts triggered domestic turmoil.

In Egypt, 80 persons were killed in rioting after the government imposed harsh economiesin an effort to make the country eligible for much-needed outside financial help. In Israel, demonstrations and scattered violence greeted a sudden decision by a newly-elected government to change the basis of the country's economy from a heavily subsidized socialism to a free-market capitalism.

For Lebanon, once the commercial and banking capital of the Middle East, 1977 was a year of disappointment.

A year ago, just months after a disastrous civil war that all but destroyed Beirut, Lebanese and world businessmen who had used Beirut as an Arab regional headquarters, were predicting that it would promptly be rebuilt and would regain much of its pre-war role.

But continuing hostilities, a Syrian occupation and political uncertainties have kept investment out of Beirut and the city has remained at a shattered standstill.

Bahrain is quickly becoming a foreign exchange center and short-term money market, but its location restricts its usefulness to the area of the Persian Gulf.

Despite the cutback in their once limitless development plans, however, the oil-producing countries of the Middle East are optimistic about their economic future-barring an ever possible outbreak of new Arab-Israeli fighting - and many are taking on new obligations for improving their own situations and those of their non-oil-producing neighbors.

Saudi Arabia, the wealthiest of the wealthy, is still far from fully exploiting its seemingly limitless oil supply. Nonetheless, in the face of a soaring inflation, it has cut back a number of major investments in heavy industry and scaled down its growth plans.

What was to have been a $1.4 billion steel plant, for example, has been reduced to a fraction of the original proposal. But other investments such as a $3 billion, 25-building university at Riyadh and a $5 billion project to set up a nationwide telephone system survived closer scrutiny and are still intact.

Saudi Arabia's full takeover of Aramco, the subject of more than two years of difficult negotiations, is expected sometime early this year. The Saudis own 60 per cent of Aramco, and four U.S. oil companies - Exxon, Texaco, Mobil and Standard Oil Co. of California - own the remaining 40 per cent.

Iran, Saudi Arabia's rival for supremacy in the Persian Gulf region, is under new economic management after Cabinet changes prompted by the inability of long-time Premier Abbas Hoveida's government to use the oil income to solve the country's serious development problems.

Power failures of up to six hours a day last summer crippled Iran's factory production and embarrassed the shah. Industrialization projects lagged badly, inflation raged at a rate of 25 per cent and the country's economy showed itself unable to absorb its 20 per cent growth rate.

Hoveida was replaced by Finance Minister Jamshid Amouzegar, a Western-style technocrat inclined toward austerity.

The country's development plans were sharply reduced; the government announced it would sell the $5 billion National Petrochemical Corp. of Iran, and Amouzegar began preparing a shift from nationalized industry to a program of encouraging private investment.

Iraq, which had already tightened its pursestrings in 1976, continued its caution last year but began to spend once again on essential major projects such as railways, dams and power generators.

Because of anti-boycott legislation passed by Congress, U.S. exports to Iraq have dropped to about half the 1976 level, but Americans appear to be dealing indirectly with Iraq through contractors from third countries such as Yugoslavia.

The smaller Persian Gulf countries, most of them with no pressing development needs, seem unaffected by the downturn in oil profit-making. Many observers, in fact, see the rivalry of the wealthy sheikhdoms producing what could one day be an expensive duplication in plants and facilities.

A vast overcapacity in billion-dollar drydock facilities appears likely, for example, with Dubai and Bahrain competing for more business from the supertankers than there is likely to be.

Over-construction of petrochemical plants and plans by the Gulf producers to expand into the oil refining business also could upset the region's economy, in the view of some experts.

The Arab oil-producing countries have traditionally been generous in their financial assistance to their impoverished neighbors and allies. Last year they took steps to put some of that assistance on a more structured footing.

The Arab Monetary Fund, which went through its final organization in 1977, is preparing to make its first loans this spring. The facility, modeled somewhat on the International Monetary Fund, is solely owned and controlled by its 20 Arab states and the Palestine Liberation Organization and has nearly half of its planned $870 million in initial capital.

Egypt, whose destitute millions absorb financial aid with little visible sign of improvement in their lot, is the major beneficiary of Arab and Western assistance programs.

Israel's economy, under a new rightist government, underwent an overnight change in October that ended three decades of carefully regulated socialism and attempted to bring new strength to an ailing financial system that is being drained by one of the region's fiercest inflations.

The government lifted most foreign currency controls, floated the Israeli pound - allowing it to drop by about one-third in value, reduced subsidies on consumer goods, increased utility charges and raised the value-added tax. As a result, prices in Israel rose 41 per cent in 1977.