Italy's decision to alleviate overcrowding of the country's unversities by closing enrollment to foreign students for at least two years has drawn harsh criticism from politicians, university officials, foreign students and diplomats.

The students - between 50,000 and 70,000 of the 800,000 here are foreigners - have come to look upon the Italian unversities, with their low costs and open enrollments as a means of getting college degredd that they were not allowed or could not afford in their own countries, government officials say.

Facilities here, however, were designed to accomodate only about 25 per cent of the present enrollment officials said. That enrollment is thought to include at least 6,000 Americans.

The ruling by Education Minister Franco Maria Malfatti will not affect the students already here, nor those with full scholarships from their native lands. It is to bring an immediate halt to all other new enrollments, including about 1,000 from the United States, that have been filed for the coming year.

Italy has been especially attractive for American medical students, largely because of the shortages of spaces in U.S. medical schools and lower costs here.

Government officials are convinced that the open enrollment policy instituted here in the late 1960s has been a major factor in bringing growing numbers of foreign students to Italy.

Representatives of Italy's other major parties have criterized the measure, saying that it will not solve the problem of overcrowding.

Socialist Deputy Aldo Aiello said the move would cut off the channel of the diffusion for Italian language and culture." The Communist Party's top education expert, Achille Ochetto, said, it would limit our country's opportunities for international relations and for cultural exchanges with the rest of the world."

The universities with the highest proportion of foreign students, are Rome, Naples, Perugia, Siena, Padua, Pavia and Bologna. In Bologna, where 10 per cent of the 55,000 students are foreigners, painted slogans in Arabic, Spanish and Greek reading, "we want to stay" appeared on building walls.

The new restriction reflects a general malaise in Italy's universities that in recent months has led to student demonstrations and rioting.

"In many cases, we don't get the cream of other countries students, but the dregs," said one government official. He said that reluctance to foot the education hills for foreign students who could not get into universities at home - as well as a desire to cut down on the influx of part-time foreign students involved in drug traffic or other illegal activities - were also behind the controversial decision.

A spokesman for Premier Giulio Andreotti said that public security was a major concern that prompted the move.

Other government officials and educators, however, say that the decision smacks of provincialism and that it could create problems for Italy's relations with some foreign countries.

A source close to Andreotti said that there already have been protests from West Germany and that Italy's relations with Greece, which sends the largest contingent of foreign students to Italy each year, may suffer.

He also said that the atmosphere of Andreotti's forth-coming trip to the United States might be somewhat tarnished as a result.

A U.S. embassy official here said that the decision was "a shame, because it comes at a time when the Carter administration is eager to increase cultural exchanges."