William C. Foster, 87, the first director of the Arms Control and Disarmament Agency and a principal negotiator of agreements to stop the proliferation of nuclear arms, the testing of nuclear devices in the atmosphere and the use of nuclear weapons in outer space, died of heart ailments yesterday at his home in Washington.

Mr. Foster was chosen by President Kennedy to head the ACDA when it was established in 1961. He continued in that post until 1969, when he retired. The treaties he helped bring into being, the first of their kind between the United States and the Soviet Union, were meant to ease tensions between the two great powers and lessen the danger of nuclear war.

To that end Mr. Foster also negotiated details of the Washington-Moscow "hotline." The need for quick and reliable communications between the White House and the Kremlin became evident during the Cuban missile crisis of 1962, when the possibility of hostilities between the two countries appeared imminent. Existing official channels between the two countries at that time were relatively slow and clumsy, and this was seen as a danger in itself: War could start by accident or through a misunderstanding.

Mr. Foster's service at the ACDA, during which he also was an ambassador to the United Nations, crowned a career in which he was the second head of the Marshall Plan, which revived the economy of Europe after World War II, an under secretary of Commerce and of Defense, and, in private life, executive vice president and director of the Olin Mathieson Chemical Corp.

After leaving the government, Mr. Foster was a member of the General Advisory Committee on Arms Control & Disarmament at the State Department. He also was honorary chairman of the Arms Control Association and a trustee of the Atlantic Council, the Institute of International Education and the George C. Marshall Research Foundation.

William Chapman Foster was born on April 27, 1897, in Westfield, N.J. He graduated from the Massachusetts Institute of Technology after serving as an Army pilot in World War I. In 1922, he went to work for the Pressed and Welded Steel Products Co. of Long Island City, N.Y. He became president of the company and continued to head it until 1946.

In that year Mr. Foster began his career in government. Although he was a Republican, he was chosen by President Harry S. Truman to be under secretary of Commerce.

In 1948, Mr. Foster went to the Marshall Plan office as deputy administrator. In 1950, he succeeded Paul Hoffman as head of the program. From 1951 to 1953, he was under secretary of Defense. From 1955 to 1961, Mr. Foster was an official of Olin Mathiesen Corp. He returned to public service with the establishment of the disarmament agency.

Mr. Foster received honorary degrees from Syracuse, George Washington, Rutgers and Yale universities and from Kenyon College. He was a member of the Metropolitan, Cosmos, Chevy Chase, Alibi and Alfalfa clubs.

Survivors include his wife, the former Beulah Robinson, whom he married on May 9, 1925, of Washington; a son, S. Robinson Foster of Detroit, and four grandchildren.