The corruption-busting U.S. attorney in New Jersey, Jonathan L. Goldstein, resigned under White House pressure yesterday and accused President Carter of backing off campaign promises to take the federal prosecutors' jobs out of politics.

"You and Attorney General (Griffin) Bell have determined that my record of accomplishment on behalf of the United States must give way to the dictate of politics," wrote Goldstein in his forced letter of resignation.

His office had drawn nationwide attention for its nonpartisan prosecution of links between politicians and organized crime, and his retention in office was considered a test of President Carter's repeated campaign pledge to do away with the political spoils system for the selection of U.S. attorneys and federal judges.

Traditionally, U.S. attorneys resign upon the election of a new administration and their successors are selected from a list submitted by senators of the party in power. Goldstein, who has worked for the Justice Department since graduating from law school 12 years ago, was appointed by President Nixon in June, 1974.

Carter has been under intense pressure from Sen. Harrison Williams (D-N.J.) to replace Goldstein with a Democrat

Goldstein said in his letter to the President that he was told by Associate Attorney General Michael J. Egan in the spring that he was likely to be replaced "because the Attorney General had received a confidential White House memorandum directing each Cabinet officer to hoor patronage requests from Democratic senators and representatives."

The Justice Department refused any comment on the letter and the White House said it could not find such a memo.

Robert Del Tufo, first assistant attorney general in new Jersey, is slated to be nominated by President Carter for the job. While Del Tufo was one of seven names submitted by Williams to the White House, he is considered by New Jersey politicians to be close to House Judiciary Committee Chairman Peter Rodino (D-N.J.).

An aide to Williams said the senator and Del Tufo have no political ties. He called Del Tufo a professional law enforcement man "who can do a better job" than Goldstein, and added, "We'd rather have our professional in the job than theirs."

But in an unusual branch of senatorial courtesy, New Jersey's Republican senator, Clifford Case, who recommended Goldstein for the job, called the forced resignation "a loss for everyone in the state no matter who his successor is and how well his successor carries on the prosecutions now in progress."

David Cohen, president of Common Cause, was even blunter. He called Goldstein's resignation "a black mark on the administration" and said, "The only reason he could have been replaced was for partisan political reasons."

Goldstein said he was told by the Justice Department Thursday, after two weeks of hints, that "the White House was pushing me to resign right then and there."

He held off until yesterday, he said, to give himself time to draft his seven-page letter to Carter, outlining how over the past seven years the U.S. attorney's office in New Jersey had prosecuted both Republican and Democratic politicians in what "was universally viewed as one of the most corrupt states, if not the most corrupt state, in the nation."

Goldstein joined the U.S. as head of its criminal division attorney's office in 1969. He came from the organized crime section of the Justice Department, where he served for two Democratic Attorneys General, Nicholas deB. Katzenbach and Ramsey Clark.

Among the politicians prosecuted by the U.S. attorney's office were a Republican and a Democratic secretary of state; a Republican and a Democratic state treasurer; the chairmen of both the Republican and Democratic state committees; 12 mayors, two congressmen; the president of the state senate, and the speaker of the state Assembly.

Goldstein said he is non-political, belonged to no party when he came to New Jersey but registered as a Republican once, in 1972, to vote for Case in a primary election.

He blamed his forced replacement on pressure put on Williams and the Carter administration by influential Democrats. He added in a telephone interview that Case resisted similar pressure when the Republicans were in power.

It was just that kind of pressure that Carter and Attorney General Bell promised to withstand in their appointments of federal judges and prosecutors.

The White House refused comment on Goldstein's letter.