Despite the opposition of rivals and some Mexican officials, International Business Machines Corp. expects to win government authorization to set up a new subsidiary to build personal computers here, diplomatic and industry sources said.

Approval of the IBM project would send a positive signal to foreign companies that have been awaiting proof that Mexico will interpret its strict foreign investment rules more flexibly in order to attract foreign investors, businessmen and western diplomats said. The IBM subsidiary would be wholly owned by the U.S. giant.

Mexico promised to make it easier for foreign investors in order to attract about $6.1 billion in outside capital over the next five years, funds crucial to the economic plan it presented to foreign bank lenders last August.

Approval of the IBM project would disappoint foreign computer firms already manufacturing here. They had to give Mexicans 51 percent ownership of their subsidiaries and also had to guarantee that by their second year of operation, half the parts required in the manufacturing process would be purchased from Mexican suppliers. IBM is expected to get some exemptions from the local-content laws, too.

The $100 million in export income the IBM project could generate is attractive to cash-starved Mexico.

The IBM investment is expected to be less than $7 million. Nearly all the 125,000 units to be assembled each year are said to be meant for export.

"We're not saying that IBM should be kept out, we are just insisting that they play by the same rules as everyone else," said Richard Hojell, chairman of Apple de Mexico, which last month opened a plant that will build 10,000 Apple personal computers here next year, one-third of them for export.

Hewlett-Packard Co. -- like Apple Computer Inc., involved in a minority joint-venture with Mexican private investors -- opened its own microcomputer plant in April with a modest initial planned annual run of 1,500 machines. "If the government had said 100 percent partnership was possible, we probably would have come in under 100 percent," said Manuel Diaz, general manager of Hewlett-Packard here and an IBM opponent.

Rodrigo Guerra, general manager of IBM de Mexico, said that his firm's request for full equity control was made "in response to the foreign investment guidelines published in February," when the government announced it would consider proposals for 100 percent foreign ownership in specific industrial categories, including computers and other high-tech enterprises.

Mexico's 1973 foreign investment law permits non-Mexicans to own more than 49 percent of a locally incorporated company only in "exceptional" cases. Wholly foreign-controlled companies established prior to the decree -- such as IBM's present Mexican subsidiary, which manufactures Selectric typewriters and mini-computers -- were exempted from the law.

The IBM proposal has sparked a sharp national debate both over the merits of the IBM project and foreign investment in general.

The influential National Electronics and Electrical Communications Chamber, which includes most of the 22 foreign and Mexican firms authorized to build PCs here, has lobbied hard against IBM since news of the proposal was leaked six months ago. Influential functionaries in the Commerce and Industrial Development ministries are said to be annoyed by IBM's bargaining tactics, which at one point included a threat to offer the investment to Argentina. In Congress, IBM proponents have been attacked as "vassals of the transnationals."

But opponents concede they probably have lost their battle.

The proposed IBM operation, which the company refuses to discuss, would be by far the largest microcomputer manufacturing enterprise in Latin America.

The plant would produce the new IBM PC-AT microcomputer. The assembly line, at first employing fewer than 100 workers, would be set up within the company's 12-year-old factory outside Guadalajara, where 360 people now work, sources said.

Competitors are upset because about 10,000 IBM units are to be sold within Mexico.

They think only 14,000 personal computers will be sold in Mexico next year and perhaps 20,000 in 1986. Officials of Apple and Hewlett-Packard said IBM, which already supplies two-thirds of Mexico's mainframe computers and half its mini-computers, would have an unfair market advantage.