WARSAW, Poland (AP) _ The government said Tuesday it has agreed to exchange ambassadors with Washington after four years of refusing to accept a new U.S. envoy because of American economic sanctions against Poland.

''Both sides have agreed upon accrediting their ambassadors,'' Jerzy Urban, the chief government spokesman, said at his weekly news conference. He said further steps were required, but of ''more a technical than a political dimension.''

In Washington, State Department deputy spokeswoman Phyllis Oakley had no comment on Urban's remarks.

Informed sources said privately that neither side had submitted names and final arrangements could be months away, but Urban's acceptance of a question on the matter from a Polish journalist indicated Poland might be ready to offer its candidate.

Poland's communist government said in February the Reagan administration's decision to lift the remining economic sanctions opened the way for the exchange.

The countries have maintained ties at a lower diplomatic level since the United States imposed sanctions to protest the December 1981 declaration of martial law, under which Poland suppressed and then outlawed the free trade union Solidarity.

Sanctions were lifted after political prisoners were freed under a government amnesty last fall.

Relations have improved since then with several high-level contacts and the State Department has said the governments have followed a step-by-step process toward normal relations. A senior U.S. official said recently that several candidates were under consideration for the ambassador's post.

The last Polish ambassador to Washington, Romuald Spasowski, defected soon after martial law was imposed and was not replaced. The United States has not had an ambassador in Warsaw since 1983, when Francis Meehan completed his assignment.

Career diplomat Jack Scanlon was nominated to replace him, but Poland said it would not accept a new U.S. ambassador until all sanctions were lifted.

The United States withdrew Scanlon's nomination in 1985 and subsequently named him ambassador to Yugoslavia.

Solidarity was created as the first free union movement in the Soviet bloc during nationwide strikes in August 1980 and then was chartered by the government. Martial law was lifted, and replaced by stiff new laws adopted by Parliament, following the outlawing of Solidarity.