In a move that underscores the growing fragmentation and instability in world oil markets, Exxon Corp. Announced yesterday that it will gradually end all sales of crude oil to companies not affiliated with Exxon.

Other major oil companies, including Standard Oil of California, once the world's largest seller of crude, are also cutting such sales as demand at their own refineries grows and more and more oil production in many nations is owned and sold by national oil companies.

The action by Exxon and other companies means many crude oil buyers will have to deal directly with a national oil company, such as the National Iranian Oil Co. (NIOC), for crude.

At the moment NIOC is selling only spot cargoes at prices up to $20 a barrel. Both Libya and Iraq have reduced sales under firm contracts at regular Organization of Petroleum Exporting Countries prices so that they can sell their crude in the spot market and make a higher profit.

Exxon said it would not renew present contracts with so called third-party markets when the contracts expire, except for a six-month period at half the volume called for in the old contract.

Hardest hit by Exxon's decision is Japan, which gets about 5 percent of its oil through trading companies that have contracts with Exxon. Last year Japan consumed about 5 million barrels of oil a day, virtually all of which was imported.

The contracts in Japan begin to exprie at the end of this month. World-wide, Exxon has between 25 and 30 such contracts covering about 500,000 to 550,000 barrels per day.

"The plain fact of the matter is that we just don't have the oil," an Exxon spokesman said. Even after eliminating all third-party contracts between now and 1982, Exxon still will not have enough crude to cover the needs of its own refineries and those of its affiliates around the world, he said.

Exxon probably was forced to its decision, according to oil industry sources, when British Petroleum canceled a contract to supply Exxon with about 300,000 barrels a day of light oil, mostly from Iran.

Iran, which formerly exported more than 5 million barrels a day, has halted all sales to the consortium of oil compaines that used to handle most of the country's exports, and now is selling only on the spot market.

But whatever caused Exxon to move now, the basic situation has been developing for years. Before 1970 the world's seven major oil companies, including Exxon and SoCal, produced and marketed almost all of the crude traded on world markets.

Now the companies have lost control of much of the crude, just as their own need for it is rising. A Chevron spokesman here said that his company's third-party sales have dropped from more than 1.5 million barrels a day in 1976 to 382,000 currently.

"We are honoring all our third-party commitments right now," the Chevron spokesman said, except for a 3.3 percent cutback that also hits the company's affiliates. But Exxon's action, he added, is "not surprising." He said his company has probably been doing the same thing without explicitly announcing it.

SoCal's sharp drop in crude sales over the last three years would seem to bear that out.

In Pittsburgh, Gulf Oil Corp. said it had no immediate plans to phase out curde oil sales to non-affiliates. In London, Royal Dutch Shell Group refused to comment.

The Exxon announcement came as on surprise to Carter administration energy experts, who were aware that the major companies have been getting out of the crude sales business.The step was seen as one more consequence of the nationalization of oil in many producing nations, particularly in the Middle East.

Another source said that the Japanese trading companies would have to find a new contract supplier, which probably is impossible right now, or "buy costly and uncertain supplies on the spot market."

Some of Exxon's contract phase-outs will affect independent refiners in the United States, but the company refused to identify them. Other countries affected include Taiwan, Canada and several nations in western Europe.

All of Exxon's customers, including affiliates, have had their crude supplies reduced by 10 percent since Dec. 1 as another consequence of the Iranian oil shutdown.