Anti-American sentiment in this Moslem country has risen perceptibly since the massacre of Palestinian refugees in Beirut, but U.S. officials here say they doubt conditions are ripe for the kind of boiling over of hostility that led to the burning of the U.S. Embassy in 1979.

Deep resentment about perceived U.S. complicity in the events that led to the massacres at the Sabra and Shatila refugee camps last month, and tacit U.S. backing of Israel's objectives in the Lebanon campaign, have left Pakistanis with bitter feelings toward the U.S. administration despite its pledge to provide $3.2 billion in military and economic aid during the next five years.

The resentment has manifested itself mostly in the state-controlled press, which has dwelled on U.S. backing of Israel in its presentation of graphic and grisly accounts of the killings of refugee women and children by Israeli-supported Christian troops.

Typical of the coverage was a bannered front-page account in Jang, an Urdu-language daily published here, which carried just beneath its massacre headline a photograph of President Reagan and an accompanying headline declaring, "Reagan Justifies Massacre." A story underneath appeared to distort earlier statements by the U.S. president that attempted to explain Israel's motivation for moving its troops into West Beirut before the massacre.

The English-language daily, The Moslem, published in Islamabad, carried on its front page the day after news of the massacre broke a photograph of piles of corpses, accompanied by detailed accounts of past U.S. support of Israeli military actions. A veteran Pakistani journalist observed that The Moslem normally does not receive news agency photographs until days after they have been received by other news organizations and that the picture may have been a file photograph of another massacre scene.

U.S. diplomats here and in Islamabad, the capital, are especially fearful of volatile Pakistani mobs because of the Nov. 21, 1979, attack on the embassy, in which two persons were killed and scores of others trapped while Pakistani security forces appeared slow in responding to appeals for help.

One diplomat said, "We're handling it low key, lest it look like we had something to do with it," meaning the massacre.

There have been no demonstrations against the United States for its support of Israel, largely because the martial-law regulations imposed in 1979 by President Mohammed Zia ul-Haq prohibit any public assembly of five or more persons.

However, the government on Sept. 22 sponsored a one-hour nationwide symbolic protest in which most factories, offices and schools closed at noon for state-approved meetings at which Israel and its supporters, including the United States, were condemned. The government said it called the protest after being urged to do so by social and religious organizations in Pakistan.

In statements about the massacre, Zia has condemned Israel and called on the United Nations to expel Israel, and he also has obliquely criticized U.S. support of Israel. But he has done so cautiously, apparently out of unwillingness to sour the air before his scheduled visit to Washington this month.

Western diplomats said there are essential differences between now and 1979, when the U.S. Embassy was sacked. Then, the United States had cut off aid to Pakistan, which it had accused of developing nuclear weapons; many Pakistanis held the United States indirectly responsible for the execution of Zulfiqar Ali Bhutto, whom Zia overthrew; and the United States had been humiliated by its inability to do anything about the hostages seized at the embassy in Tehran.

But the catalyst for the 1979 attack on the Islambad embassy was the terrorist attack on the holiest of Moslem shrines, in Mecca, which had been attributed here to a plot by the United States and Israel.

The accumulated grievances spilled into the streets, and Zia failed to respond forcefully to stop the violence.

This year, however, diplomats noted, President Reagan is not perceived by Pakistanis as being on the defensive as then-president Carter was during the hostage crisis, and the fervently fundamentalist Islamic government in Iran is too preoccupied with its war against Iraq to devote attention to agitating Pakistani sentiment, as it did in 1979.

But the most powerful deterrent to anti-U.S. violence, diplomats said, is the $3.2 billion that Zia is counting on to prop up his ailing economy and buttress his military.