Two Soviet cosmonauts returned safely to earth yesterday after nearly 140 days in orbit, a new endurance record.

During their stay in space they conducted experiments that could lead one day to space stations producing exotic new computer crystals and other materials impossible to manufacture well on eath.

Col. Vladimir Kovalanok and flight engineer Alexander Ivanchenkov landed in Kazakhstan, Central Asia, aboard their Soyuz 31 space craft. They left the Salyut 6 space station in electronic mothballs, its systems idle, awaiting the arrival of another crew to resume manning it.

"A preliminiary medical checkup at the landing site showed that the cosmonauts well withstood the long orbital flight," Tass, the official Soviet news agency, reported. The two had been exercising regularly and using special pressure suits to increase muscle tone and blood circulation in their limbs. The Russians found that previous long-duration space orbiters needed aid in walking their first days back on the ground.

Jubliant Soviet space officials hailed the cosmonauts' 4 1/2 months in space precisely 139 days, 15 hours - as one more step toward the goal of permanently manned orbital stations with crews shuttled back and forth. Cosmonaut training chief Vladimir Shatalor said the fight had been "brilliantly completed. It would have been difficult to wish that things could have gone better than they did."

During their weeks in space, Kovalenok, 36, and Ivanchenkov, 38, were visited by two pairs of cosmosnauts - including a Pole and an East German and three unmanned supply craft ferrying fuel and food vital to extending the usable life of the l9-ton Salyut.

The "Progress" supply such homey articles as a guitar, fur boots, strawberries, fresh milk, and onions and garlic to the cosmonauts, who stressed the importance of such humdrum touches.

Space flight director Alexel Yeliseyev in a recent Novosti interview asserted that the only physiological barrier to extremely long space flights seemed to be psychological conditions.

"Man findshimself in a small collective extremely far away from home, relatives, friends. It is more difficult to solve the psychological loads."Yeliseyer said, however, that so much is being learned on this score that he is certain more longer flights can be made.

The Soviets, who reportedly are building their own reusable space shuttle similar to the U.S. craft now being tested, have talked increasingly of the possibility of manned interplanetary flights.

At the same time, they have with the successful completion of this flight seemingly ironed out the troubles that plagued the Salyut program, including an embarassing problem last year when the first Soyuz crew to visit the Salyut 6 failed to dock and had to return to earth just as the country was hoping for a space spectacular of the October Revolution.

Tass said yeaterday "more than 50 experiments were conducted in conditions of weightlessness to obtain new semiconductor and optical materials, metallic alloys and compounds."

The Soviets have shown keen interest in crystal growing in a gravity-free environment.

"Some crystals may possess new mechanical, electrical and thermal properties," Yeliseyer said, "greater strength, or superconductivity. In the electronic and laser industries, results convincingly show production of such crystals in space can be profitable. In other words, it may prove advantageous to send spacecraft only for the purpose of growing crystals."

Other experiments by the cosmonauts included photographing the Soviet union , and parts of East Germany and Poland to help detect "dynamics of changes of vegetation cover, water balance of rivers and other seasonal natural phenomena," Tass said.

The two will be widely hailed and feted in these days just before the Nov.7 celebrations of the 61st anniversary of Soviet power.