Soviet dissident Georgi P. Vins, newly arrived in the United States, attended President Carter's Sunday school class yesterday and found himself likened to the just man in the day's Old Testament lesson who was persecuted for his faithfulness to God's teachings.

Inevitably, as the president developed the lesson, the Soviet Union was cast in the role of the ruthless biblical ruler of ancient Israel who permitted oppression and deceit to gain his ends.

At no time did the president, who volunteers to teach the Couples' Class at First Baptist Church every few weeks, mention the Soviet Union by name, but his repeated allusions to Vins' willingness to suffer for his convictions made the analogy obvious.

Vins, pastor of a Baptist group not officially recognized by the Soviet government, had been serving a sentence in a labor camp in exile for hisreligious activities. He was one of five dissidents released by the Soviets and flown to this country last Friday in exchange for two convicted Soviet spies.

The lesson for the day in the Sunday class' study guide, prepared by the denomination's national Christian education department, was on the theme of justice.

"There could hardly be a better lesson," Carter said of the theme, noting that "four days ago, Pastor Vins was in a cattle car being transported from Siberia-an exile in his own country because of his belief in Christ."

The biblical story on which the lesson was base in recounted in the Old Testament book of Kings. In the story, Naboth, a farmer, rejected the request of King Ahab to sell the Israeli king a portion of his land because Judaic laws forbade Jews from selling portions of their inheritance.

Ahab's Queen Jezebel plotted to have Naboth accused of a capital crime and arranged false witnesses to testify against him. When he was executed on the basis of this false testimony, Ahab took over the property he was earlier refused.

In his 35-minute lesson, President Carter constantly drew contemporary analogies from the ancient tale and from the presence of the Soviet pastor, who listened intenly to the remarks, translated by an interpreter.

"It is difficult for us in a free society to obey God," Carter said, "even though we are encouraged to do so by good [civil] laws, by the Constitution" in which, he said, the founding fathers who were believers incorparated the laws of God.

How much more difficult it would be to obey the laws of God, he speculated, "in a society which seeks to seduce us from God . . . through the television . . . through the school."

In another reference to the biblical story, he observed that Queen Jezebel "decided to silence Naboth. But there was no Siberia in Israel so she decided Naboth would have to be destroyed . . . The whole system of justice was subverted in order to get rid of a voice that spoke from God."

Another element in such subversion of justice, he said, was secrecy. "In addition, the news media had to be controlled," he said. With a smile, he projected contemporary White House-style news coverage onto the Naboth scandal. "Can you imagine the headlines? 'Israeli justice subverted,' or editorials calling for a investigation.

"In order to subvert man's law there has to be secrecy and deprivation of those governed to know the truth," he said.

He added that the "circumventing of the truth" of King Ahab's reign involved "elements still in use in someparts of the world."

The president also drew some morals for Americans from the lesson on justice. He quoted the slogan: "My country, may she always be right, but right or wrong, my country," and observed: "I doubt that God would approve that statement.

"The first time I ever had to face that in my lifetime was in the Vietnam war . . . If my president says "bomb Cambodia,' so be it."

For citizens to challenge such actions "doesn't mean we were unpatriotic," he said. "But our citizens have the right and the duty to inquire into the rightness of our nation's actions."

Carter concluded his lesson by telling the class, which appeared to have more visitors than regular members crowded into the ornate church's balcony: "I would like to remind you, and I will remind myself, that the people of God who know Christ must represent the cause of justice on behalf of the oppressed everywhere."

According to a church official, the president had specifically asked that Vins be present at the church yesterday. Vins was escorted to the church service after Sunday school by the president and sat with him in the Carter family pew.

The president had promised to attend a service at the Washington Cathedral yesterday in a memorial to the victims of the Holocaust. Rosalynn Carter and the couple's son Chip went to the cathedral service. CAPTION: Picture, Georgi P. Vins, left with President and Mrs. Carter and First Baptist Church pastor Charles A. Trentham. The unidentified woman at left is interpreter.