When Jose Lopez Portillo was sworn in Dec. 1 as Mexico's 60th president, the onlookers included delegations representing 102 nations, among them a very special group from north of the border.

Secretary of State Henry A. Kissinger was here. So were Rosalynn Carter and Jack Ford. As they moved about this capital, the Mexican government, press and public accorded them a superstar status that sometimes seemed to overshadow the attention being paid Lopez Portillo.

"It was actually embarrassing," recalls a U.S. diplomat. "We kept trying to warn the Mexican's that they were overdoing it - that they might offend some of the other foreign visitors. But the Mexicans made it clear that it was something they wanted to do."

In diplomatic circles, the blue-ribbon American delegation and Mexico's enthusiastic welcome were seen as a sign that both the United States and Mexico are eager to make a fresh start toward improved relations after a long period of strain.

The tension stems from the six-year presidency of Lopez Portillo's predecessor, Luis Echeverria. As part of his effort to stir up a domestic climate of populist reform, Echeverria sought actively to diminish the vast U.S. influence in Mexico and to align his country closely with the attitudes of the Third World.

His tactics - constant scolding of the United States for its economic policies toward poor nations, championing Fidel Castro and Salvador Allende, voting against the U.S. position on key questions in the United Nations - caused considerable irritation in Washington.

"There was never anything like an open break," one diplomatic source said. "Echeverria was careful of avoid outright Yankee-baiting, and Washington was careful to keep its temper on a leash. They still smiled in public. But relations were not good."

These strains went largely unnoticed in the United States, where the tendency is to take Mexico for granted despite America's big stake in Mexican events and the innumerable ways they can affect the lives of Americans.

If peasant squatters in northwestern Mexico seize private farms and disrupt agricultural production, American housewives are likely to find few tomatoes and melons on their supermarket shelves.

If Mexican authorities relax their campaign to spot and destroy this country's opium-poppy fields, more illegal heroin will be smuggled into the United States and American narcotics addiction will rise.

Unemployment and economic hardship in Mexico will inevitably mean a drop in the imports - more than $5 billion in 1975 - that make Mexico the United States' fourth-largest customer.

Hard times will increase the number of illegal immigrants - already estimated by the U.S. Immigration and Naturalization Service at as many as 6 million - who American officials and union leaders say take jobs away from U.S. citizens.

Most important, the almost 2,000 miles of border the two countries share make Mexico the proverbial "soft underbelly" of the United States and give Americans a strong vested interest in the stability and good will of their southern neighbor.

While Americans are only dimly aware of these facts, it is a different story on the Mexican side of the border, where a brooding love-hate attitude toward the United States has always played an important role.

Among the first things every Mexican schoolchild learns is how the United States, more than a century ago, pressured Mexico into a war that cost his country half its territory, what are now all or most of the states of California, Texas, Arizona, New Mexico, Utah, Nevada and Colorado.

The resentments kindled by that loss were kept burning in subsequent years by the incursions of American corporations with their wholesale pillaging of Mexico's natural resources, and by the web of economic interdependence in which Mexico always has been the weaker partner.

Today, the United States is by far Mexico's biggest customer and supplier, it's biggest outside investor and the biggest holder of its foreign debts. When all the adding and subtracting is done, the arithmetic always comes out the same way: Mexico perennially buys and borrows much more from the United States than it sells.

For a long time, through the 1930s, there was almost perpetual mutual animosity. Those were the days when Mexico's revolutionary governments were expropriating American oil and mineral holdings and jingoistic U.S. congressmen and editors viewed the Mexican "red menace" with an alarm more recently reserved for Fidel Castro's Cuba.

Over the ensuing three decades, however, a pattern emerged in which Mexican governments seemed happy to follow the U.S. lead in international affairs in exchange for massive American investment, loan and tourist revenues to fuel its growth. In Washington, Mexico came to be regarded as an occasionally prickly but generally quiet and reliable ally.

Mexican foreign policy was described as "concentrating 80 per cent on relations with the United States, 15 per cent on Latin America and 5 per cent on the rest of the world." Then came Echeverria.

A Mexico City banker recalls how Echeverria went up to New York to address the U.N. General Assembly shortly after taking office in 1970, said the banker:

"We thought he was going to talk about tomatoes. There had been some trouble about discrimination against Mexican tomato exports. Instead, he startled everyone in the country by giving this big lecture on the India-Pakistan dispute and how to solve the Middle East problem. It wasn't at all the sort of thing that you'd come to expect from a Mexican president.

"And," the banker continued, "it had a ripple effect that went through the whole government. Before you knew it, the most minor bureaucrats in the most obscure governments offices were giving interviews to the newspapers about the problems of Bangladesh or the drought in Sub-Saharna-Africa."

Many people here take the cynical view that Echeverria sought influence in Third World circles primarily because he wanted to cap his presidency by becoming U.N. secretary general. He did campaign actively for the job, but at the end of the year his hopes were dashed when Austria's Kurt Waldheim was given a new term.

Others think Echeverria was trying to marshal support for his domestic reform programs by playing to the latent anti-American feelings of Mexico's leftist intellectuals. Still others argue that he sincerely believed that Mexico's best interests lie in seeking some "third force" course between American capitalism and Soviet communism.

Whatever the reasons, Echeverria's efforts to become a spokesman for the Third World became a crusade - one that saw him travel the world to participate in international conferences and establish new diplomatic ties with 62 nations, largely in Africa, Asia and the Middle East.

At home, his campaign did not seem to have much impact. Most Mexicans were either annoyed at the cost of his bid for international prominence or amused at the solemnity with which he went around the country naming dams and otehr public works after the Third World.

In Washington, his efforts were not regarded as amusing. In one extreme reaction reminiscent of the jingoism of an earlier day, a group of conservative U.S. congressmen sent President Ford a letter, charging that Mexico was being prepared for a Communist takeover.

That was a misreading. The State Department dismissed the letter as irrational and uninformed. But even within State, he was regarded, in the words of one diplomat, as "a pain."

Frictions reached their peak, when Mexico voted for the U.N. resolution equating Zionism with racism. That not only angered Washington officialdom, it also caused American Jews to boycott Mexico's beach resorts with an effectiveness that has cost the important Mexican tourist industry some $200 million in the past year.

In many respects, the Jewish boycott marked the start of a turnabout in Mexico's foreign policy. The drop in tourist revenues was just a small example of a recent reaction that has given the Mexican economy its worst battering in years and brought the country to the brink of financial crisis.

Lopez Portillo, who as Echeverria's finance minister indulged in his own share of tough mationalistic talk, appears to have decided that it is time to soft-pedal the class-struggle rhetoric and mend fences with Washington.

Some of Lopez Portillo's very first appointments underscored the emphasis he clearly intends to put on better relations with the United States. Jose de Olloqui, Mexican ambassador in Washington until last month, was named undersecretary of the Foreign Ministry; many sources here believe he shortly will become foreign minister. As the new ambassador, Lopez Portillo picked Hugo Margain, who held the job in the pre-Echeverria years from 1965 to 1970 and is highly respected in Washington.

"There won't be any sudden and dramatic announcements that Mexico is abandoning its Third World positions," a diplomatic source predicted. "It's just not done that way. The government will continue many of the associations to which Echeverria committed it.

"But," he added, "there will be a pregressive movement from the front to the back row. On a lot of questions that may be of big concern to the Arabs or the Africans, but that have little to do with Mexico, you won't see the Mexicans up front any more. Slowly, the whole Third World thing will just wither away."

If that happens, most diplomatic sources agree, U.S.-Mexican relations should quickly slip back into their old pattern of relative harmony despite occasional economic frictions, with the Mexicans continuing feeling that they are getting the short end.

The biggest problems are almost certain to be over continuing illegal immigration. The Mexicans, who find the situation a handy safety valve to take pressure off their domestic burden of overpopulation and unemployment, privately make it clear that they are not going to do much about it.

In other areas, the Mexicans are showing a strong disposition to spend money and effort on cooperation with Washington. Even in Echeverrla's time, Mexico committed itself to an ambitious and continuing program of trying to stamp but narcotics smuggling across the border - something the Mexicans regard as an American rather than a Mexican problem.

Although Mexico has recently discovered petroleum reserves that could make it one of the world's prime producers, it earned Washington's gratitude by keeping aloof from the Organization of Petroleum Exporting Countries.

Throughout Mexico, there seems to be a growing realization that, like it or not, the imperatives of history and geography require the Mexican people to be on good terms with their American neighbors. What they would also like to see is a similar realization north of the border.