BAGHDAD, IRAQ, DEC. 29 -- Iraq and the Soviet Union have agreed on terms for the release of an estimated 2,500 Soviet workers whose departure from Iraq had been delayed because of a contractual dispute, diplomatic sources said today.

The agreement, reached during a visit here this week by Soviet Deputy Prime Minister Igor Belousov, resolves a long-standing dispute over the largest single group of expatriate workers staying in Iraq against their will, and it could lead to an improvement in relations between Baghdad and Moscow, one diplomat said.

Included in the agreement are an estimated 200 Soviet military advisers whose continued presence here was regarded by Western observers as an Iraqi hedge against the possibility that Moscow would share military intelligence with the United States. Until Iraq's invasion of Kuwait in August, Moscow had been Iraq's chief supplier of military expertise and hardware, including thousands of tanks, helicopters and jet fighters Iraq would use in the event of a war.

The vast majority of the expatriates, however, are Soviet oil field workers whom Iraq had, until this month, sought to keep in the country until their work contracts are completed. Moscow will pay an undisclosed amount as compensation to Iraq for the severed contracts. Diplomats said the payment will cover about 3,000 workers out of the 7,000 who were in the country when Iraq invaded Kuwait.

The Soviet workers affected by this week's agreement technically have been free to leave Iraq for the past three weeks, and they have been trickling out of the country aboard weekly flights of the Soviet airline Aeroflot. Aeroflot is the only airline other than the Iraqi national carrier, Iraqi Airways, known to have regular service to Baghdad. A diplomat said the flights are believed to have been loaded with food and supplies for Iraq as part of the conditions for the Soviets' release.

As recently as Dec. 4, more than 3,300 Soviet citizens were reported in Iraq. On that day, Iraq's ruling Revolutionary Command Council said all Soviet workers were free to leave. Iraq later made their departure conditional upon reimbursement for their broken contracts, an action that contributed to a sharp public rebuke of Iraq by Soviet President Mikhail Gorbachev.

Under the agreement reached during a 30-minute meeting Thursday between Belousov and Iraqi President Saddam Hussein, all remaining Soviet workers in Iraq would have the option of leaving the country by Jan. 10, the diplomats said. Moscow will not begin paying off the canceled work contracts until after Jan. 15, which is the U.N.-imposed deadline authorizing the use of force if Iraq has not withdrawn from Kuwait by then.

About 160 Soviet workers are expected to remain in Baghdad as caretakers of Soviet facilities here, the diplomat said. As many as 1,000 Soviet workers have elected to stay here, even under the heightened risk of war, rather than return to the economic and political chaos prevailing in the Soviet Union.

In addition to the Soviets, as many as 100 Czechoslovak expatriate workers and three British petroleum specialists remain here pending resolution of their work contracts. A Czech diplomat said the release of his fellow nationals is imminent.

Minor formalities are believed to be blocking the departure of the three Britons, who worked as safety specialists at an Iraqi liquid petroleum gas plant. Iraq is reportedly concerned that Iraqis at the site have not been adequately trained so the plant can be left in their charge.

The Iraqi media today and Friday railed against the United States and Britain for intercepting an Algerian "peace ship" this week as it steamed through the Arabian Sea toward the Iraqi port of Umm Qasr. The government said the ship was carrying 250 women and children from 10 Arab countries and a cargo of "medicine and powdered milk." More than 450 U.S. and British soldiers boarded the ship "armed with machine guns and grenades" and began "beating the crew and women activists on board" before forcing the ship to anchor off the coast of Oman, the statement said.

A U.S. military account said the boarding party had fired smoke and stun grenades to end a scuffle begun by members of the ship's crew.