Oil ministers of the Organization of Petroleum Exporting Countries agreed in principle tonight on a plan designed to stem the slide in oil prices by setting new individual production ceilings to contain the world oil glut.

After huddling all day in an emergency session, the ministers decided to reduce their joint output ceiling by at least 1 million barrels a day to shore up the official OPEC price of $34 a barrel. The ceiling at present is 18.5 million barrels.

The key breakthrough came when the ministers concurred on a set of individual production quotas that will more than double Iran's allocation and limit Saudi Arabia's share to 5 million barrels a day or less.

Some ministers warned, however, that the package could fall apart Monday if members were unable to resolve a pricing dispute between Persian Gulf Arab states and African nations. Some members may raise or lower prices by $1 or $2 a barrel to solve the problem.

The tentative agreement on production quotas alters ceilings that were accepted by OPEC in an accord reached last March but that effectively collapsed in July. The protracted recession has greatly diminished world oil demand and prompted several members, notably Iran, Libya and Venezuela, to court new buyers by discounting prices and pumping oil at levels higher than their assigned shares.

As a result, Saudi Arabia has been forced to cut its production from 7 million barrels a day under its previous quota and now produces as little as 4.3 million barrels to uphold OPEC's pricing structure.

The widespread discounts offered by some members have caused major U.S. oil companies to balk at paying the OPEC price of $34 a barrel.

The Saudis and their gulf Arab allies generally have stuck to the official reference price, but oil industry sources here say that 70 percent of the world's oil is now being sold at discounts of as much as $5 below that level.

To achieve an agreement, the Saudis were prepared to accede to Iranian demands to bring the cartel's quotas closer into line with existing production levels. In return, the Saudis apparently received assurances that discipline would be restored to prevent an outright price war that would jeopardize OPEC's existence.

Following tonight's meeting, Iran's oil minister, Mohammed Gharazi, said, "We all agreed on three things: to maintain the $34-a-barrel price, to set the new production ceiling between 17 and 17.5 million barrels and to establish new quotas."

Venezuelan Oil Minister Humberto Calderon Berti suggested that the remaining pricing dispute would not prevent an accord, saying, "If we really respect the quotas, we won't have problems with the pricing differentials."

The gulf states, led by the Saudis, want to readjust prices so that their crude sells for significantly less than oil produced by Nigeria, Libya and Algeria. The Africans have been stealing buyers from the gulf states by offering roughly the same prices, or even discounts, even though African crude is preferred by oil companies because it is lower in sulfur and cheaper to refine.

The gulf states were considering either lowering their prices by $1 or $2 a barrel while the Africans kept their prices stable, or asking for a price increase by the Africans.

The deep world recession is only one of the factors that has contributed to a sharp fall in world oil demand. Warm winter weather, the cumulative impact of conservation measures and the switch to other forms of energy have accelerated a steep drop in oil production from OPEC's peak of 31 million barrels a day produced in 1979.

In addition, oil industry officials said that companies were drawing down inventories and refraining from buying as much as 2 million to 3 million barrels a day in anticipation of a further decline in prices.

"This was one of the most important sessions that OPEC has ever held," Venezuela's Calderon Berti said.

In the morning session, Saudi Oil Minister Ahmed Zaki Yamani sketched a depressing scenario of the world economy and emphasized that OPEC must adjust to the increasing indications that an economic recovery still remains dubious.

Mana Said Oteiba of the United Arab Emirates, who is usually one of the most upbeat of OPEC ministers, said that world oil demand will fall another 2.3 percent this year after dropping 5 percent in 1982. While predicting a possible recovery in 1984, he suggested that the recession might even linger into 1985.

"This is the worst crisis OPEC has ever faced and could be a turning point for the whole oil industry," he said.

"Our production today is about 17.4 million barrels a day, but it could go down to 16 or even 15 million barrels a day by the summer if the current economic situation continues," he said.

Before the conference, the four U.S. oil companies in the Aramco group, which buy the bulk of Saudi crude, sought to exert heavy pressure on Saudi Arabia to push through a cut in either prices or production to stabilize oil markets.

The Saudis and their gulf allies have resisted any price reductions because they feared triggering a new wave of cuts that could spiral into a price war.

Moreover, bankers have warned that a sudden drop in prices could endanger Mexico and Venezuela, two oil producers that are deeply in debt and dependent on high oil prices to ward off possible bankruptcy.

OPEC has failed at several meetings since last March to thrash out an acceptable quota agreement. At their most recent meeting in Vienna before Christmas, the ministers raised the OPEC production ceiling to 18.5 million barrels a day but could not reach a consensus on how to apportion the shares.

Consequently, those countries that adhered to the official OPEC price, such as Saudi Arabia and Kuwait, lost many customers and demanded a new show of discipline by renegade members to keep the cartel together.

Under the new quotas, Kuwait will be permitted to return to a production level of 1.1 million barrels a day after falling to a low of 650,000 barrels a day to keep down oil surpluses.

Libya, which was pumping 1.5 million barrels or twice as much as its proposed share last year, has agreed to reduce its production to 1.2 million barrels a day.

Venezuela, which felt obliged to exceed its share to pay off pressing debts, was persuaded to cut its output to 1.8 million barrels a day from a current level estimated at 2.1 million barrels.