President Carter suggested for the first time yesterday that the shah of Iran may not survive that country's continuing upheaval, and offered his sharpest criticism yet of the shah's record on human rights.

Speaking to reporters, as concern was growing in his administration about the safety of Americans in Iran this weekend, the president appeared to some officials who deal with Iran to be putting a small but significant measure of distance between the administration and Shah Mohammad Reza Pahlavi.

Asked if he thought the shah would survive, the president said, "I don't know. I hope so. This is something that is in the hands of the people of Iran."

Saying that the primary U.S. aim is to achieve "an absence of violence and bloodshed," Carter stressed in his remarks the importance of "the Iranian people's relationship with the West," and pledged that the United States would not intervene in any way "in the internal political affairs of Iran."

White House and State Department officials said later that the administration still supported the shah and that Carter's remarks did not represent any dramatic shift of U.S. policy toward Iran.

But senior administration sources suggested that the comments did reflect what one official called "an ongoing and agonizing reappraisal" by the White House of the shah's future and of what U.S. ties to Iran might look like without the shah in command.

Increasingly convinced that the shah cannot survive, some working-level officials have been quietly -- and unsuccessfully -- urging the administration to take steps to separate U.S. goals in Iran from the embattled ruler's fate.

"The White House didn't believe there was any acceptable alternative to full support for the shah before now," one foreign policy analyst said yesterday. "Now, I get the feeling that if somebody came up with a good analysis of what to do, they would listen. They are at least asking the right questions."

In previous public statements, the president and his foreign policy advisers had expressed full and immediate confidence in the shah. Privately, their position was that no statements or actions could be made that might be interpreted as a loss of confidence in the shah, since in the White House view there was no viable political alternative to his rule.

Carter appeared to edge away from that position yesterday in his remarks at a routinely scheduled breakfast meeting with reporters, who heard Carter suggest that the United States would accept a new government dominated not by the shah, but perhaps by other political forces.

"We personally prefer that the shah maintain a major role in the government, but that is a decision for the Iranian people to make," Carter said.

At several other points, the president emphasized U.S. regard for "the Iranian people" rather than the shah, a formulation often used in diplomacy to avoid identification with a specific regime.

"I don't have any apology to offer for the difference in human rights values that our own nation espouses and those that have been accomplished by the shah in Iran," Carter said. "There have been abuses" under the shah, he added.

Carter went on to cite the shah's efforts to move Iran "toward democratic principles and social liberalization," but the president's defense of the Iranian ruler was much weaker than at Carter's most recent news conference on Nov. 30. "We trust the shah to maintain stability in Iran," Carter said then.

But the growing fears of possible outbreaks of anti-American violence and organized terror attacks during this weekend's crucial, highly emotional, holy mourning days of Moharram for Iran's Shiite Moslems have become an important policy consideration in recent days, U.S. officials said.

The new willingness at the White House to think about an Iran without the shah was signaled earlier this week by the appointment of George W. Ball, former under secretary of state in the Kennedy and Johnson administrations, as a temporary consultant on Persian Gulf affairs to the National Security Council, administration sources said.

Reports from State Department officers, Secretary of Treasury W. Michael Blumenthal and Sen. Robert C. Byrd (D-W. Va.) on a series of separate recent meetings in Iran with the shah and some opposition leaders have also had an influence on what is described as a new "openness" to Iranian proposals at the White House, according to U.S. officials.