Spain's socialist government today took over 18 banks and 240 companies controlled by Rumasa, the country's largest conglomerate, contending that Rumasa was on the verge of bankruptcy.

Explaining the measure, Finance Minister Miguel Boyer said the government had acted to safeguard shareholders, depositors and the jobs of Rumasa's 60,000 employes from business practices that were threatening "the entire financial system" of Spain. He stressed that the move, termed under Spanish law an "expropriation," did not represent a move toward a nationalization policy.

Claiming that Rumasa's situation was one of "extraordinary gravity and danger," Boyer charged the group had ignored "the most elementary rules of banking caution." He accused Rumasa of "systematically obstructing tax authorities" and said that its executives had time and again reneged on commitments to produce properly audited balance sheets.

The Rumasa crisis is a major one for Spain, which had come to view the 22-year-old firm as the symbol of the nation's economic takeoff in the '60s.

Rumasa Chairman Jose Maria Ruiz Mateos, 51, built a small family vineyard and wine concern into a huge holding company that included banking and insurance, shipping, construction, hotels and department stores. The Rumasa group last year accounted for 1.8 percent of Spain's gross national product, reporting revenues of $2.7 billion, up $1 billion from 1981.

The takeover was announced in a broadcast shortly before midnight yesterday. Hundreds of Rumasa employes and depositors promptly made their way at that hour to Rumasa's headquarters, where police held back the crowds.

At a press conference today, Boyer claimed that since 1978 Rumasa had repeatedly ignored warnings from the central bank about an increasingly dangerous concentration of risk among the group's banks and companies.

Boyer asserted that the Rumasa banks' shares were five times overvalued, and that $159 million was owed in taxes at the end of 1980. Rumasa's capital and reserves, he said, were only $38 million, not the $917.5 million it claimed.

Boyer said that the crisis point had been reached as a result of the "political weakness" of previous Centre Party governments. He said they had failed to insist that Rumasa put its house in order and that the only alternative for the present socialist government had been expropriation.

The Rumasa success story--Ruiz Mateos started the business with $3,000 and seven employes--had dazzled Spaniards. The group logo of a bee is omnipresent above store and office windows around the country.

The group was the country's leading hotel chain, its premier wine producer and exporter, its leader in the cattle and agriculture industry, its second-largest department store operation and among its top five companies in real estate and construction. Taken together, the Rumasa banks were the eighth biggest financial institution in Spain, with total deposits of $14.8 billion, according to Rumasa figures.

Rumasa claimed to control about 400 companies, a total constantly revised by new purchases. But only 240 companies and 18 banks were listed in the takeover decree because, Boyer said, the government had been unable to determine the number of Rumasa affiliates.