Iranians went to the polls today on the issue of establishing an Islamic republic, the goal of the resolution led by Ayatollah Ruhollah Khomeini.

There were reports, however, that a campaign to boycott the referendum was having an impact in the rebellious Kurdistan and Turkoman areas.

In the Iranian Kurdish capital of Sanandaj, scene of heavy fighting last week, so many ballot boxes were stolen that residents were forced to go to the countryside to vote.

Meanwhile, the revolutionary government announced the resignation of the defense minister, Adm. Ahmad Madani, and his replacement by a little-known general, Taghi Riahi. Reasons for the unexpected change were not clear.

Referendum voting is to continue Saturday and the results are expected Sunday. The electorate is thought to number about 20 million in a population of 34 million. Voting age was dropped to 16 from 18. About one sixth of the voters are members of national minority groups that have expressed various degrees of discontentment since the revolution.

When Khomeini went to vote near his residence in the Shiite Moslem holy city of Qom, his car was so heavily mobbed that he had to hand his "yes" vote out through the car window to be passed inside and placed in the ballot box.

At a number of polling places both in prosperous north Tehran and in the southern slums, poll watchers were able to say exactly how many no votes there had been. It was never more than three or four out of a thousand.

Voters were handed a perforated slip, half of which was written in green, the traditional color of Islam, that said, "To change the former regime to an islamic republic whose constitution will be approved by the nation. Yes." The other half was printed in red and said the same thing, except for the final word, "no."

In front of the poll watchers, the voter had to tear the slip in half and place one part in the ballot vox and the other part in a waste basket.

The day before the voting, the American wife of an Iranian had said that, as a citizen by marriage, she intended to vote because she thought it dangerous not to have a stamp on her identity card if she wanted to leave the country. "I'll vote 'no' unless there's any hint that they can tell," she said. "If they can, I'll vote 'yes'."

Her Iranian husband said he would not vote despite her pleas. Many middle-class Iranians have been saying they would boycott the polls, but few opponents were willing to risk voting negatively.

A woman was seen putting two "yes" votes in the ballot box. Asked why, she said she was also voting for her sick mother. A poll official said he had no reason to disbelieve that her mother was sick.

At some places, men and women were made to stand in separate lines, at others they could stand together. Most women in well-off north Tehran seemed to be wearing a variety of street clothes, ranging from blue jeans to elegant suits. Only about a quarter of the north Tehran women wore scarves to hide their hair, or wrap-around veils. As Khomeini has counselled.

In the poor areas of south Tehran, all women wore chador and lined up separately.

The replacement of Adm. Madani according to the announcement, had Khomeini's approval. Madani is to remain as naval chief of staff. His replacement came just two days after that of the armed forces chief of staff, Gen. Mohamed Vali Qarani - who had refused to recognize Madani as his superior.

In an interview Wednesday, Madani had seemed very much in control of what little remains of the disorganized armed forces.

Gen. Qarani had been replaced just hours before in what then appeared to be a victory for Premier Mehdi Bazargan, a moderate who favors trying to rebuild the armed forces as a smaller but more or less conventional military establishment. Today, there was no mention of Bazaran's having played any role in the dropping of Madani.