An Afghan Foreign Ministry official, sent here to defend his government at a special meeting today of the nonaligned nations called to discuss Soviet interference in Afghanistan's internal affairs, instead denounced the Soviet invasion of his country and defected on the spot.

The nonaligned group then voted by acclamation to have its chairman -- the Cuban ambassador -- cable Kabul with a humanitarian appeal for the safety of the wife, four children, three sisters and mother left behind by 33-year-old Abdul Rahim Ghafoorzai.

The action today stunned diplomats from about 90 nations, who had gathered behind closed doors expecting to hear the Soviet presence defended by Ghafoorzai, an 11-year career diplomat who was deputy director of the International Relations Department in the Afghan Foreign Ministry.

Speaking to reporters after the meeting, he said he had yet decided whether he would seek to stay in the United States, go elsewhere or "join all my compatriots who are in the liberation struggle."

Ghafoorzai said his decision was prompted during his trip with Afghan Foreign Minister Shah Mohammed Dost to Moscow, where he realized that Soviet forces "are not in Afghanistan as a result of a request made by our government."

It was then, he said, that "I decided to express the views of my people. I realize my statements here would have more weight" than any action he might take in leaving Kabul quietly, even though that might provide more protection for his family.

Ghafoorzai conceded that the pro-Soviet coup in 1978 "involved some reforms which had the support of the Afghan people." He said that coup had been supported by Moscow.

But by now, he said, "Even the Soviet Union realizes it cannot convince the world it is there because of imperialist intervention, and the liberation struggle under way will convince the Russians to withdraw."

He said he had no personal knowledge about the circumstances surrounding the death of former president Hafizullah Amin in late December, when Soviet troops moved to topple his government and install Babrak Karmal. But he said that the situation in Kabul now is that "the Afghans are not governing themselves."

He confirmed reports of widespread attacks on Soviet soldiers in the cities of Afghanistan, citing one incident shortly before he left last Friday in which four to six Soviets were killed in the capital.

In a speech delivered to the nonaligned group, he reportedly chided that movement for failing to speak out and "take prompt action against an invasion by a superpower." The meeting had long been sought by Pakistan and other members of the group who wanted to put the nonaligned nations on record against the Soviet invasion. It had been delayed by the Cubans, but was finally scheduled for this week.

Ghafoorzai sat silently by two days ago during a bitter procedural wrangle over the agenda of the nonaligned meeting, according to diplomats who were there, and finally spoke out today after Pakistan introduced the sub-subject.

Aside from the cable on behalf of Ghafoorzai's family, no decision was taken at today's meeting, and the nonaligned nations will continue their debate Monday.