W. Beverly Carter Jr., who became a career diplomat and held three ambassadorial posts after working for many years as an editor and publisher of newspapers oriented toward the black community, died yesterday at Suburban Hospital after a heart attack. He was 61.

Mr. Carter, who retired from the foreign service in 1980, was stricken yesterday while on a visit here from Geneva where he was a U.S. member of the U.N. human rights commission.

In 1975, Mr. Carter, then serving as the first black American ambassador to Tanzania, became a controversial figure in connection with negotiations that led to the release of three Americans and a Dutch woman kidnaped from Tanzania by rebels from neighboring Zaire.

Details on the bargaining that led to the release of the four never were made public, but Mr. Carter was withdrawn from the embassy in Dar-es-Salaam, and his expected appointment as ambassador to Denmark was tabled. Mr. Carter's removal reportedly was ordered by Secretary of State Henry Kissinger, who told reporters when questioned about the incident that, "We are trying to maintain the policy that terrorists can not negotiate with American officials."

Late in 1975, while Mr. Carter was reassigned to the State Department here and his diplomatic career appeared in jeopardy, 250 persons attended a dinner in his honor and were told by former D.C. Mayor Walter E. Washington that "America should be proud to have produced a great man who cares about humanity, knows when to draw the line and makes decisions for the best."

In 1976, the Senate restored Mr. Carter to ambassadorial status, approving his nomination as envoy to Liberia.

The vote followed Foreign Relations Committee hearings at which Rep. Charles Rangel (D-N.Y.), acting as a spokesman for the Congressional Black Caucus, asserted that the withdrawal of Mr. Carter's expected appointment to Denmark was "astonishing and undeserved punishment for a man who had acted in the finest tradition of our nation's diplomatic service."

After returning from Monrovia in 1979, Mr. Carter served as ambassador-at-large.

He was born Feb. 1, 1921, in Coatesville, Pa., grew up in Philadelphia, and after receiving a bachelor's degree from Lincoln University, studied law at Temple University.

He spent 12 years in Philadelphia in a variety of journalistic posts, including that of city editor of the Philadelphia Afro-American, from 1945 through 1948. He ran unsuccessfully for Congress in 1954, and from 1955 to 1964 was publisher of The Pittsburgh Courier.

After joining the U.S. Information Agency, his first overseas post was as press attache at the U.S. embassy in Nairobi, Kenya, in 1965-66. Following service as counselor to the embassy in Nigeria and deputy assistant secretary of state for African affairs, he was named ambassador to Tanzania in 1972.

In 1972, before going overseas, he was acting chairman of the D.C. Board of Higher Education.

He was married in 1971 to Carlyn Brown Pogue, and he had a son, William Beverly III and two stepchildren, Dion Pogue and Ann V. Pogue.