BUENOS AIRES, Argentina (AP) _ Film director Fernando Solanas was shot eight times in the legs outside his studio Wednesday night. From his hospital bed, he blamed what he said was a government-related ''mafia.''

Solanas, whose film ''Sur'' won the best director prize at the 1988 Cannes Film Festival, had appeared in court Monday to defend himself in a libel suit filed by President Carlos Menem.

Solanas was sued for a recent editorial stating that Menem had ''betrayed and defrauded'' Argentinians who elected him in July 1989. Solanas also charged that a ''mafia'' of corrupt Menem advisers were running the country.

Two men waiting for Solanas in a car outside the studio on the outskirts of Buenos Aires opened fire with machine guns, according to Solanas' spokeswoman, Elba Ferreira. All the wounds were to Solanas' legs.

Speaking to reporters before he entered surgery, Solanas said the gunmen had shouted, ''Son of a b.... shut up 3/8''

The attack is ''one of the devious actions of a mafia power that is robbing the country blind,'' he said without elaborating.

Menem condemned the attack and said he had ordered a ''rapid and exhaustive investigation to bring all the weight of the law on the guilty.''

An anonymous caller later threatened a leading human rights activist with a similar attack, according to the activist, Hebe de Bonafini of the Mothers of the Plaza de Mayo.

''The bullets we have for won't hit the legs - We'll be going for your head,'' she quoted the caller as saying. De Bonafini's group held scores of demonstrations during the military dictatorship of the 1970s and early 1980s.

De Bonafinia also has been sued by Menem for libel.

Solanas's films often deal with gritty political issues. ''Sur'' (South) was a film of life in Argentina during the 1982 Falklands War with Britain. The war led to the 1983 overthrow of the military regime.

''Tangos: The Exile of Gardel,'' about the Argentinian musician's life in Paris, was nominated in 1986 for an foreign film Oscar. Solanas also co- authored the early 1970s left-wing political classic, ''Hour of the Furnaces,'' among other works.

His latest film ''El Viaje'' (The Trip), about a youth searching for his father, was to open in Argentina this summer.