The violent demonstrations sparked by the shah of Iran's visit have dumped on President Carter's doorstep a vivid reminder of the contradictions that his advocacy of human rights has imposed on U.S. foreign policy.

The contradictions stem from conflicting ideas of how the administration should deal with a regime that has been accused of massive human rights violations but that also has vital economic and strategic ties to the United States.

In the view of Shah Mohammad Reza Pahlavi, who regards his government as one of Washington's most important allies, it is these latter considerations that should be uppermost on the minds of the President and his advisers.

The shah didn't come to Washington for a lecture on human rights in Iran. Instead, his purpose was to discuss Iran's role as a major supplier of crude oil to the energy-short United States and as a customer eager to use its oil riches to buy sophisticated U.S. weapons and industrial technology.

To many human rights partisans, the reception accorded the shah already has been taken as proof tht the administration is following a double standard. The administration, they charge, makes a big show of human rights concern when dealing with small, unimportant countries, but shoves its scruples into the background for nations whose business or cooperation it wants.

That charge is vigorously denied by administration officials. They say the White House is aware and concerned about the rights situation in Iran, that U.S. diplomats have prodded the shah's regime to make improvements and that human rights was "high on the agenda" of subjects for discussion between the President and the shah.

What's more, the officials add, while the leverage that Washington employ is limited, the administration's efforts already have produced some betterment in the way that Iranian dissidents are treated. Further improvements, they insist, can best by achieved not by ostracizing the shah but by cooperating with him and encouraging him to do still more.

Underlying the controversy is the indisputable fact that Iran, while ostensibly a constitutional monarchy, actually is a tightly controlled dictatorship whose power rests on the passive acceptance of most of its 33 million people.

Those who don't like the shah and his government are kept in line by a network of police and intelligence forces, of which the most infamous is a shadowy, military-controlled organization known as SAVAK.

In the past, SAVAK has been charged by foes of the regime with engaging in systematic murder, torture and imprisonment of dissidents. Its agents reportedly operate far outside the borders of Iran, and there have been frequent charges that it is involved in attempts to harass and intimidate Iranian students and other opponents of th shah in the United States and elsewhere.

The shah's regime has justified the activities of agencies like SAVAK on the grounds that a firm hand is needed to guide Iran's populace out of its feudal traditions and into a modern state. Repression, the shah's supporters claim, is used only against Communists and others who seek to subvert Iran's march into the modern world.

In recent years, though, this justification has met with increasing skepticism outside Iran; and, with the Carter administration's fanning of human rights into a major issue in foreign policy, the shah has been under increasing pressure to soften his regime's repressive image.

In an interview with U.S. public television broadcast on Monday night, the shah charged that most opponents of his regime "are Marxists, anarchists wearing masks. I would be very much interested to see how many Iranians are behind those masks."

But he also was careful to add: "Torture does not exist anymore in my country."

State Department officials say that they have not received any allegations of tortune within Iran in several months. Similar findings, they add, have been reported by such private human rights, watchdog organizations as Amnesty International.

In addition, U.S. officils say, the shah recently has taken such other "positive steps" as inviting the International Red Cross to inspect Iranian prisons and interrogation centers, instituting prisoners being tried by military courts greater rights to counsel and open court proceedings, and releasing approximately 2,200 prisoners.

But, the officials concede, these moves, while encouraging, are still only minimal first steps. The say that roughly 2,200 political prisoners remain in Iranian jails and that dissent is still kept on a very short rein.

Opponents of the shah go further, charging that the recent improvements were cosmetic changes intended to please the Carter administration without really altering the repressive nature of the regime.

In recent testimony before a House International Relations subcommittee, Richard W. Cottam, a professor of political science at the University of Pittsburg and a man with long experience in Iran, noted that the Carter human rights policy has had effects in Iran that are "both very encouraging" and "also very dangerous."

While conceding that some of the improvements "are not simply cosmetic," Cottam warned that the regime could turn to more subtle, hard-to-detect forms of repression. His warning has been echoed by other critics who charge that the regime has turned from blatant forms of torture to methods like putting people in mental institutions.

However, another view was given the same subcommittee by William J. Butler, executive committee chairman of the international Commission of Jurists and a man who personally consulted with the shah on some of the legal protections now being introduced in Iran.

He credited Carter with heightening interest in human rights all over the world and said: "While it is true that the Shah of Persia is not going to become a flaming liberal overnight, there is evidence that in Iran significant changes are occuring, at least at a minimal level."