Iran surprised the Islamic foreign ministers' conference here today by making eight Afghan rebel leaders members of its conference delegation, handing a sharp setback to efforts by the Soviet Union to win recognition from the Moslem world for the Babrak Karmal regime it installed in Afghanistan.

The move places Iran more firmly on the side of Moslem rebels trying to overthrow Babrak. It comes at a time when the Iranians apeared to be more dependent on Soviet supply lines to overcome the U.S. economic boycott of Tehran -- imposed because of the Iranian seizure of American hostages.

Iranian Foreign Minister Sadegh Ghotbzadeh said, "It means we are going all the way" with the rebels, known at the conference as freedom fighters.

The Carter administration has been trying to convince Iran that the Soviets, with troops poised in its borders, pose a greater threat than the United States. The United States promised aid against the Soviets once the hostages are freed.

Now, without ackowledging that it is siding with the United States, Iran took a giant step against the Soviet position. At a special session of the Islamic foreign ministers' conference in January, Iran denounced the Soviets' December invasion of Afghanistan but was more concerned with condemning the U.S. threat of economic sanctions.

Ghotbzadeh, who did not attend the January meeting, took a different tack today. "It's just our duty," he said with a smile.

Ghotbzadeh said he told the Pakistani hosts that Iran planned to add the Afghan rebels to its delegation. "If Iran wants them included there's nothing we can do," said a top Pakistani official.

Making the rebels delegates under the Iranians' wings give them a massive psychological lift as well as the to participate in debates as full members. The conference plans to take up the Afghan question Monday or Tuesday.

It also takes some of the heat off the Pakistanis who by giving Afghan refugees aid and allowing rebel groups to set up headquarters in the border city of Peshawar have drawn sharp attacks from the Soviets and their Afghan allies.

The Kabul government was suspended from the Islamic conference at the January meeting, to which it sent no representative. This time, however, conference officials reported that Afghanistan said it intended to come even though it was not invited. So far, no Afghan government officials have shown up.

The Soviets have waged a major diplomatic offensive to gain recognition for the Babrak government. They proposed through the puppets rulers in Kabul a meeting of Afghanistan, Iran and Pakistan -- which would mean recognition by those two countries of the Babrak government -- as a way of getting the 85,000 Soviet troops out of Afghanistan.

The Soviets have said Pakistan's refusal to hold talks with Kabul is making it harder to pull the troops out.

Iran's move today appeared to deal a blow to Moscow's diplomatic effort to obtain the neighboring state's recognition of rulers in Kabul.

Iran is also expected to push for a strong condemnation of the United States both for the boycott and for last month's aborted military rescue of the hostages.

There are increasing indications, however, that the conference might try to take some steps behind the scenes to help get the hostages freed.

Iran, in allowing rebel groups as delegates to the conference, chose carefully among the rival groups.

It picked heads of the five member grops of the Peshawar-based Islamic Alliance for the Liberation of Afghanistan, which formed in January as a result of pressure from the Islamic conference to unify the rebel factions. In addition, the head of the alliance, Abdul Rahsoul Sayaf was included as a delegate.

Heads of other rebel groups based in Peshawar, including the powerful fundamentalist Moslem Hezbi, Islami, were not made members of the Iranian delegation.

The other two rebel members represent groups based in Iran who are fighting in western and central Afghanistan.

The rebel leaders attending the conference said they have not received aid either from the West nor from other Islamic nations. Sibghtullah Mujaddidi, head of the National Liberation Front, said the rebels need ammunition, antitank weapons and weapons that they can use against Soviet Migs and helicopters.