TEHRAN - The Jewish women in the back rows of the synagogue wear long garments in the traditional Iranian style, but instead of chadors, their heads are covered with cheerful, flowered scarves. The boys in their skullcaps, with Hebrew prayer books tucked under their arms, scamper down the aisles to grab the best spots near the lush, turquoise Persian carpet of the altar. This is Friday night, Shabbat - Iranian style, and the synagogue in an affluent neighborhood of North Tehran is filled to capacity with more than 400 worshipers.

It is one of the many paradoxes of the Islamic Republic of Iran that this most virulent anti-Israeli country supports by far the largest Jewish population of any Muslim country.

While Jewish communities in Syria, Iraq, Yemen, Egypt, Morocco and Algeria have all but vanished, Iran is home to 25,000 - some here say 35,000 - Jews. The Jewish population is less than half the number that lived here before the Islamic revolution of 1979. But the Jews have tried to compensate for their diminishing numbers by adopting a new religious fervor.

''The funny thing is that before the Islamic revolution, you would see maybe 20 old men in the synagogue,'' whispers Nahit Eliyason, 48, as she climbs over four other women to find one of the few vacant seats. ''Now the place is full. You can barely find a seat.'' Parvis Yashaya, a film producer who heads Tehran's Jewish community, adds: ''We are smaller, but we are stronger in some ways.''

Tehran has 11 functioning synagogues, many of them with Hebrew schools. It has two kosher restaurants, and a Jewish hospital, an old-age home and a cemetery. There is a Jewish representative in the Iranian parliament. There is a Jewish library with 20,000 titles, its reading room decorated with a photograph of the Ayatollah Khomeini.

Khomeini protection

Iran's Jewish community is confronted by contradictions. Many of the prayers uttered in synagogue, for instance, refer to the desire to see Jerusalem again. Yet there is no postal service or telephone contact with Israel, and any Iranian who dares travel to Israel faces imprisonment and passport confiscation. ''We are Jews, not Zionists. We are a religious community, not a political one,'' Yashaya said.

Before the revolution, Jews were well-represented among Iran's business elite, holding key posts in the oil industry, banking and law, as well as in the traditional bazaar. The wave of anti-Israeli sentiment that swept Iran during the revolution, as well as large-scale confiscations of private wealth, sent thousands of the more affluent Jews fleeing to the United States or Israel. Those remaining lived in fear of pogroms, or massacres.

But Khomeini met with the Jewish community upon his return from exile in Paris and issued a ''fatwa'' decreeing that the Jews were to be protected. Similar edicts also protect Iran's tiny Christian minority.

Just as it radically transformed Muslim society, the revolution changed the Jews. Families that had been secular in the 1970s started keeping kosher and strictly observing rules against driving on Shabbat. They stopped going to restaurants, cafes and cinemas - many such establishments were closed down - and the synagogue perforce became the focal point of their social lives.

Jewish school in Shiraz

Iranian Jews say they socialize far less with Muslims now than before the revolution. As a whole, they occupy their own separate space within the rigid confines of the Islamic republic, a protected yet precarious niche.

Jewish women, like Muslim women, are required by law to keep their heads covered, although most eschew the chador for a simple scarf. But Jews, unlike Muslims, can keep small flasks of home-brewed wine or arrack to drink within the privacy of their homes - in theory, for religious purposes. Some Hebrew schools are coed, and men and women dance with each other at weddings, practices strictly forbidden for Muslims.

''Sometimes I think they are kinder to the Jews than they are to themselves. ... If we are gathered in a house, and the family is having a ceremony with wine or the music is playing too loud, if they find out we are Jews, they don't bother us so much,'' Eliyason said.

''Everywhere in the world there are people who don't like Jews. In England, they draw swastikas on Jewish graves. I don't think that Iran is more dangerous for Jews than other places.''

Some problems exist

Testimony from Jews who have left Iran suggests more serious problems than those cited by Jews inside the country. In written testimony to a congressional subcommittee in February 1996, an Iranian Jew complained of being imprisoned for two years on trumped-up charges of spying for Israel. He also said his arrest was preceded by harassment at work and pressure to convert to Islam. Inside Iran, Jews say that they frequently receive alarmed telephone calls and letters from relatives in the United States concerned about their well-being, but that they themselves do not feel physically endangered. Their major complaint is the inability to visit family in Israel, and what they say is inadequate funding for Hebrew schools, which are administered by the Iranian Ministry of Education.

Although many Jews hold jobs in government ministries or within state-owned firms, they say they are unlikely to rise to top positions. In addition, Iran's strict Islamic law, or ''sharia,'' contains many discriminatory provisions toward non-Muslims.

Jews 'part of Iran'

Still, Jewish leaders say their community has far stronger roots in Iran than other Middle East Jewish communities, which were virtually eradicated by massive immigration to Israel in the 1940s and 1950s. Esther, the biblical Jewish queen who saved her people from persecution in the fifth century B.C., is reputed to be buried in Hamadan, in western Iran. The grave of the Old Testament prophet Daniel lies in southwestern Iran.

''We are different from the Jews of the diaspora. You see the name 'Persia' in the Old Testament almost as often as the name 'Israel.' The Iranian Jews are very much part of Iran,'' said Gad Naim, 60, who runs the old-age home in Tehran. Iranian Jews trace their history to the reign of Persia's King Cyrus. As the Bible tells it, Cyrus conquered Babylonia in 539 B.C., liberated the Jews from captivity, and raised funds for the rebuilding of their destroyed temple in Jerusalem. The return of the Jews to Jerusalem at that time was accompanied by a large migration to the lands that were then Persia, and now Iran.

In Esfahan, an Iranian city fabled for its intricate Persian tile work, the first Persian Jews were settled under the reign of Cyrus. The ancient city was once known as Dar-Al-Yahud (''House of the Jews'' in Farsi), and as late as the 19th century it was the home of 100,000 Jews, according to Elias Haronian, head of Esfahan's Jewish community.

Today, the city is a repository of Jewish lore. It has a cemetery with Jewish graves 2,000 years old, stunning synagogues and Jewish mausoleums with tiles to rival those of the mosques - but a population of only 1,500 Jews.

What happened to the Jews?

Some converted centuries ago. Indeed, in Muslim villages surrounding Esfahan, a distinctive Jewish dialect of Farsi is spoken, and Muslims still follow certain Jewish rituals, such as lighting candles on Fridays. Others left for Tehran, or for California or New York. Some went to Israel.

''It is not that life is so difficult for us, but a minority is a minority... We are like a glass of water in the sea,'' Haronian said. Haronian, a petroleum engineer, worries less about persecution than about the faltering Iranian economy, the lack of job opportunities for his four children, and the shortage of suitable Jewish spouses. ''There are very few Jewish boys here. There are so few of us,'' said his 17-year-old daughter, Shirin. At Esfahan's Hebrew school, students confided that they are deeply torn between a love of their homeland and a desire to escape from the stifling isolation of Iran.

The decision to stay or go may rest largely on Mohammad Khatami, a relatively progressive cleric who won a landslide election May 23 as the next president of Iran. Although he is virulently anti-Israel in his public comments, Khatami was considered sympathetic to the Jews during his term as Iran's minister of culture and Islamic guidance. He paid a campaign visit to a social club for Jewish women in Tehran. ''We expect more freedom, an easier life, not just for Jews, for everybody,'' said Farangis Hassidim, an administrator of Tehran's Jewish hospital.