The United States has agreed to buy nearly 110 million barrels of Mexican oil for its strategic petroleum reserve in its first direct purchase of crude oil from another government.

Under the agreement Mexico will pump 24 million barrels into the reserve by the end of the year. Shipments are scheduled to begin Sept. 1 at an averge rate of 200,000 barrels a day. From January, 1982, to the end of August, 1986, the reserve will buy 50,000 barrels a day under the agreement.

Added to other purchases, the Mexican oil should be enough to fill the reserve a third of the way to its 750-million-barrel goal by the end of this year. The Mexican oil will lift the reserve's rate of fill from the current 350,000 barrels a day to more than 500,000 barrels a day in September, according to reserve officials.

The contract may mark a new chapter in the stormy history of energy relationships between the United States and Mexico. Negotiations for a natural gas deal two years ago left bitter feelings on both sides when U.S. demands for lower gas prices sparked anti-American sentiment throughout Mexico.

U.S. oil companies generally gave the Mexican agreemnt good reviews. "I think the U.S. basically did us a favor," said a supply chief for a major oil company who agreed to an interview on the condition that neither he nor his company be identified. "I like the idea that the Mexicans and other governments see that the U.S. government will not buy crude at above-market prices." The supply chief said that the agreement would help private oil buyers obtain crude at better prices.

While U.S. officials would not disclose the quality of the Mexican oi to be purchased, a Department of Energy statement said all purchases would be made at the official selling price of Pemex, the Mexican state oil company. Currently, a 50-50 mixture of Mexico's light Isthmus and heavier Maya crudes sells for $31.50 a barrel. The price of the crude shipments will be renegotiated quarterly.

Richard Furiga, deputy director of the reserve, yesterday said "it's a very attractive commodity contract." Furiga cited the contract's lengthy five-year term as well as the fact that the agreement allows the oil to be carried in U.S. ships. Shippers and maritime workers have long argued that more of America's oil imports should be carried in U.S. flag ships.

Furiga said that with the Mexican shipments, filling of the reserve should be "right on schedule" for the rest of 1981. The reserve now contains 180 million barrels of crude oil in its underground caverns, and it expects to have 250 million by the end of the year in salt domes along the Texas and Louisiana coast. Congress authorized $3.9 billion -- enough for more than 120 million barrels of oil at current prices -- in a special off-budget account for the 1982 fiscal year.

In Mexico, the Mexican Industrial Development Ministry said that the sales for the last four months of this year would help compenste for the damage done during July by the world oil glut. Mexico now exports less than 1.3 million barrels daily, down from more than 1.4 million in May. The export cut came in spite of a price cut in early June, which was partly retracted later.

For the first four months of this year, Mexican exports to the United States averaged 422,000 barrels per day, or less than 7 percent of total U.S. imports. Mexico's total oil production is over 2 million barrels a day.

An Energy Department spokesman said the Mexican deal bears no relation to speculation that the United States might swap oil produced on the Alaskan North Slope for Mexican crude going to Japan.

The agreement was generally seen as having little if any impact on crude prices in view of the current world oversupply of oil. "On a global scale, 24 million barrels is rather small," said John Lichtblau, head of the independent Petroleum Research Foundation Inc. "It's important because it givves us that amount on a secure basis," he said, "but it's not going to have any impact on world supplies because we have such a surplus."

Oil traders interviewed yesterday applauded the reserve's new government-to-government approach, which cuts out the middleman. "They've always wanted an American company as a broker, and I think that's kind of foolish," said one.