Armed gunmen kidnaped the South African ambassador here today in the first such attack against a foreign diplomat since a coup six weeks ago.

An embassy spokesman said Ambassador Archibald Garner Dunn, 58, was leaving the embassy for lunch when he was seized by at least 10 men armed with submachine guns, who threw him in the back of a stolen van and fled.

None of the leftist guerrilla groups involved in similar attacks this year against diplomats has claimed responsibility for today's kidnaping.

Dunn, who has served here for six years, was the subject of an unsuccessful similar kidnaping attempt, in which his driver was killed, soon after his initial arrival in El Salvador.

Attacks against foreigners are a frequent tactic of the far left here in their war against the rightist military. Last May, Swiss Charge d'Affaires Hugo Wey was shot to death when he tried to escape a kidnap attempt. That same month, both the French and Venezuelan ambassadors were held hostage in their embassies for several weeks before being released unharmed. Numerous foreign businessmen have been kidnaped over the past several years by leftists demanding high ransoms.

But although a march against the U.S. Embassy had to be disbrushed with tear gas late last month, such attacks virtually had ceased following an Oct. 15 coup that ousted the rightest government of former President Carlos Romero.

The new government, a five-mmber civilian-miltary junta, has promised a number of social, economic and political reforms. Based on its acquiesence to demands for a freeze on bus fares and food prices nearly three weeks ago, El Salvador's largest mass group on the left, the Popular Revolutionary Bloc, declared a 30-day truce from political violence.

But the country's four active guerrilla organizations, which serve as armed forces allied to the mass popular organizations, apparently have refused to recognize the truce.

In the past several weeks, the Popular Liberation Force, the largest of the guerrilla groups, has caused serious damage to at least two small airports in the country, and burned down the MacDonald's restaurant in San Salvador.

A number of peasants, presumably members of ORDEN, a rightwing local spy network of the Romero government abolished by the new junta, have been assassinated, apparently by guerrillas.

The Popular Liberation Force also claimed the murder today of Lino Guzman, 52, former mayor of San Martin, 12 miles east of the capital.

Guzman, whose friends said he was linked to ORDEN, published an open letter in San Salvador newspapers Tuesday complaining that "lies" about him were "putting my physical integrity in danger."