A D.C. Superior Court judge yesterday ordered four Moslem fundamentalists to stand trial for criminal contempt of court and criminal trespass as a result of the four-month long takeover of the Islamic Center Mosque on Massachusetts Avenue NW by demonstrators.

The dispute over the center, part of longstanding religious divisions between Sunni and Shiite Moslems that came to world attention after the Iranian revolution, came after an Oct. 18, 1981, order by the center's board of governors to close the mosque for several weeks to repair the building. Part of the building had been damaged last May in a firebombing.

About a dozen demonstrators -- allegedly led by Bahram Nahidian, an Iranian-American rug dealer in Georgetown believed by law enforcement officials to be the leader of Moslems here who support the Ayatollah Ruhollah Khomeini -- occupied the mosque and refused to leave. The group also filed suit to stop the closing.

The center's board, made up of ambassadors of a number of Islamic nations to the U. S., countersued. A Superior Court judge last October ordered the demonstrators to leave the building and end the protest.

The center's lawyers reported to the court last week that the demonstrators had not left the building. Judge Robert Shuker yesterday ordered Nahidian, Mir Zarrin, also from Iran, Tariq Khan, from Pakistan, and Aboul-Qassim, an American Muslim, to stand trial for defying the court order and for trespass. Criminal contempt of court and criminal trespass each carry maximum prison sentences of six months.

All four said they could not afford an attorney. Shuker ordered them to return today to see if they qualified to have lawyers appointed for them. He set no date for trial.

Shuker also ordered them, as a condition of their release, not to return to the mosque or to a house across Massachusetts Avenue also owned by the center.

Nahidian, who told reporters after the hearing that he was not a leader or a "follower of anyone, only Islam," said the court battle was a "problem among Moslems" and blamed the police and the media for "trying to divide the Moslem community."

Nahidian, carrying a religious book, said he had a petition of support with 545 signatures and predicted his side eventually would win the legal battle.