The worst crisis in the 21-year history of the Organization of Petroleum Exporting Countries, although apparently over, has seriously weakened the oil cartel and isolated its most hard-line members.

OPEC's production ceilings are helping finally to bring under control a major oil glut that had been depressing prices, but the cartel has been forced to cut its total production by about one-third since 1979 to prevent a price collapse. Production by OPEC's 13 members earlier this year dipped below production by other noncommunist countries for the first time, signaling a major decline in OPEC's clout in world oil markets.

As a result, OPEC's prices are likely to remain frozen until the end of this year and possibly beyond, despite forecasts of rising oil demand in coming months, OPEC ministers and U.S. industry and government oil specialists say. The current period of price stability, which began in January 1981, will almost certainly last longer than the 18-month, OPEC price freeze in 1977-1978.

Industry analysts say OPEC's two most outspoken supporters of higher prices in the past--Libya and Iran--will have to wait for a major political upheaval in the Middle East before prices can rise again as dramatically as they did when they more than doubled in the wake of the 1973 Arab-Israeli war and of the 1979 Iranian revolution.

Meanwhile, these countries are having to sell their oil at embarrassing discounts to keep buyers who would prefer to deal with oil producers less likely to raise the price at the first sign of a tighter market, according to OPEC and industry sources.

OPEC oil ministers--here for a regular, semiannual conference that ended here yesterday--publicly expressed confidence that the cartel's production ceiling of 17.5 million barrels a day had put OPEC back in control of world oil markets. Some ministers, however, said their private views were more guarded.

"Although the victory is in sight, OPEC has to watch its action very carefully or let the victory slip," Indonesian Oil Minister Subroto said.

The meeting extended the life of OPEC's first formal production limits, which were adopted in March to cope with the glut.

The ceilings have been credited with halting a year-long slide in prices on spot oil markets, which was undercutting OPEC's official prices grouped around $34 a barrel. Spot oil prices are for individual cargoes sold on the open market and are regarded as a more accurate measure of supply and demand than official OPEC prices, which are used for long-term contracts.

The ceilings forced production cutbacks that took some oil off the markets and encouraged a bullish psychology among traders by giving the impression that OPEC was acting assertively to protect its interest.

The glut, which took hold firmly at the start of last year, resulted from a combination of slack demand caused by slow economic growth and conservation measures and increased supplies from non-OPEC members such as Mexico and Britain. As spot prices fell, oil companies added to the supply by draining inventories to avoid being stuck with high-priced crude and to trim financing charges.

To prop up prices, OPEC was forced to reduce its production from an average of 30.5 million barrels a day in 1979 to an expected 19.3 million this year, according to Department of Energy figures.

Demand for OPEC oil is expected to start rising again in the second half of the year as companies replenish inventories and the U.S. economy revives. New demand would not push up prices, however, but cause OPEC to start raising its production again. With unused production capacity of up to 10 million barrels a day left from three years ago, demand would have to recover considerably before prices could start spiraling, U.S. oil executives say.

"You'll have to see a revolution before you get a sharp jump in the price," one industry source said.

Saudi Arabia, OPEC's largest producer and traditionally its leading moderate, has 3.5 million barrels a day of spare capacity and says it will use it if necessary to prevent a sudden rise in the price. Saudi Oil Minister Sheik Ahmed Zaki Yamani has said he would like to see the current $34 price stay unchanged through 1983.

In acting to keep prices unchanged, the Saudis would undoubtedly draw criticism from hard-line OPEC members who are also the Saudis' political rivals in the Arab world. But the Saudis have shored up their image within the cartel this year by threatening to cut their own production as much as necessary to defend the prices and by tolerating the current production ceilings. The Saudis have historically opposed formal OPEC ceilings, partly out of fear that the militants might use them to push up prices artificially.

The militants, meanwhile, faced criticism at this meeting for undermining the cartel's solidarity, according to OPEC sources.

Iran, an OPEC maverick since the overthrow of the shah, is reported to be producing at least 600,000 barrels a day more than its allotted ceiling of 1.2 million and has sold oil at $3 to $6 below the official price.

Iranian Oil Minister Mohammed Gharazi denied to other ministers at the meeting that his country was breaking the accord, but he was not widely believed, according to a senior OPEC source. The source said some ministers feared Iran's excess production could wreck the entire accord on ceilings, but oil company executives say the agreement will most likely survive unless additional countries produce beyond the limits.

Libya was criticized by Yamani at the meeting for reportedly offering under-the-table discounts to keep up its production, OPEC sources said.

Short of expelling the errant members, however, OPEC has little choice but to tolerate such activities.