Relative stability for world oil prices for the past several months has given oil companies and analysts increasing confidence that the industry has moved past the worst of the problems caused by last year's roller-coaster price ride.

The trends, which promise some recovery for the battered profits that plagued major oil companies into the first quarter of 1987, have helped boost the stock prices of major oil companies beyond the gains of the overall market.

Officials stressed, however, that stability hasn't lasted long enough or reached a high-enough price level to spark a revival of U.S. exploration and production activity that plummeted as crude oil prices fell last year from about $30 a barrel to less than $10.

Industry officials said they are still afraid of being fooled again. "You may see a kick-up in drilling next year if the drillers deem the price stability is there for a longer period of time," said Richard Sparling, director of economic studies at the Independent Petroleum Association of America in Washington.

Some officials said several threats still exist that could send prices soaring or sinking. Those threats include shifts in demand, continued overproduction by OPEC members like Iraq and developments in the Iran-Iraq war, as well as the battle for clout between price-dove Saudi Arabia and price-hawk Iran.

"It's important for world prosperity that oil has a price that's reasonably predictable," said William M. Brown, director of energy studies at Hudson Institute in Indianapolis. "Then, manufacturers around the world and people in the oil business know what to do, how to invest. The real threat to an economy is when you think you know what to do and you turn out to be wrong, which happened in the 1970s."

Average gasoline prices have increased about 12 cents a gallon since they bottomed out in November, reaching 96.56 cents, according to the Los Angeles-based Lundberg Survey, and analysts predict they may top $1 this summer.

The Organization of Petroleum Exporting Countries, which has essentially stuck to lowered production ceilings and an official average of $18 in recent months, is largely responsible for the stability. Slowly increasing demand has also helped dry up last year's oil glut.

OPEC's output is critical to balancing world supply and demand.

Analysts expect OPEC, led by Saudi Arabia, to stick with the $18 price when it meets in Vienna June 25. The group is also expected to raise production quotas slightly to levels agreed on in December. "Prices will reflect the overall struggle in the gulf between the forces of accommodation led by Saudi Arabia and the forces of confrontation led by Iran," said G. Henry Schuler, director of energy security programs at the Georgetown Center for Strategic and International Studies.

"There is a change in the industry's attitude because people think the price is more likely to go up than down," said Theodore C. Eck, chief economist for Amoco Corp.

Between late February and mid-May, domestic oil companies outperformed the overall market by 22 percent and international oil companies did so by 15 percent, said Sanford Margoshes, oil analyst at Shearson Lehman Bros. Inc. "The oils should beat the market by another 5 percent by the end of this year," he said.