The United States and the Soviet Union engineered an unusual trade yesterday in which two alleged Soviet espionage agents jailed here and an American being held in Moscow were released in the custody of their ambassadors.

Under terms of the agreement, the two Soviets and American businessman Francis J. Crawford still face charges and their future court appearances have been assured by Ambassadors Anatoliy F. Dobrynin and Malcolm Toon U.S. officials said yesterday.

They said they could recall no such arragement in the past.

The officials cautioned, however, that the trade didn't necessarily mean there would be an immediate further swap so the accused persons could return home. "The cases just aren't equal," one official said.

The two Soviet citizens. Valdik A. Enger and Rudolf P. Chernyayev, were being held on $2 million bail each after their arrest last month. The two United Nations employes were charged with paying $20,000 in cash for secret antisubmarine warfare documents being supplied by a U.S. Navy officer who was cooperating with the FBI.

In what was widely viewed here as a Soviet response, Crawford, an International Harvester official, was arrested a few weeks later and charged with violations of Soviet currency laws.

President Carter mentioned Crawford in his nationally televised press conference yesterday, warning that the arrest might scare off other American businessmen. "We've had a very hard time trying to determine if there is any grounds for his arrest, and the Soviet press . . . has already condemned him," Carter said.

The general tenor of the president's remarks about relations with the Soviet Union, however, seemed designed to take the edge off weeks of increasingly shrill rhetoric on each side. The arrests of the alleged espionage agents and Crawford added to the tensions between the two superpowers.

Some American officals expressed concern privately yesterday about equating Crawford's release with that of the two Soviets becaue the Soviets face much more serious charges. They face life inprisonment if convicted. Crawford could get an eight-year sentence.

The arrgements for yesterday's tradeoff were made during recent discussions between Dobrynin and Secretary of State Cyrus R. Vance, officials said.

The plan began to unfold at 3 p.m. yesterday in Newark, N.J., when an assistant U.S. attorney produced a letter of assurances from Dobrynin during a hearing on ball for the two Soviets.

U.S. District Court Judge Frederick B. Lacey released the two men after the prosecutor said the Justice Department was satisifed that the pair would not leave the country and would show up for later court appearances.

Lancey had turned down an earlier request to reduce the usually high bond despite previous assurances by Dobrynin. "We got stronger assurances this time," one Justice official said.

A third Soviet citizen was taken into custody with the pair but was released because he had diplomatic immunity. He was attached to the Soivet mission at the United Nations and has since left the country.

Crawford was dragged from his car at a traffic light in Moscow two weeks ago and was charged with selling U.S. currency to Soviet citizens at speculative prices.

He has been held in prison but was expected to be released last night into the custody of American Ambassador Toon.

About the time of Craford's arrest, the Soviets also announced that they had ordered Martha D. Peterson, a Central Intelligence Agency agent posing as an American diplomat, out of the country last summer because of her alleged complicity in a murder.

This recent escalation of spy charges was predicted by State Department and CIA officials at the time of the May 20 espionage arrests in New Jersey. But Attorney General Griffin B. Bell pushed for prosecuting the two Soviet U.N. officials and was backed by Carter.

Yesterday tradeoff was the first recent sign of more amicable ways to settle problems in the sensitive field of superpower spying and retaliation.