Members of the American Psychological Association have voted to prohibit consultation in the interrogations of detainees held at Guantánamo Bay, Cuba, or so-called black sites operated by the Central Intelligence Agency overseas, the association said on Wednesday.

The vote, 8,792 to 6,157 in a mail-in balloting concluded Monday, may help to settle a long debate within the profession over the ethics of such work. Psychologists have helped military and C.I.A. interrogators evaluate detainees, plan questioning strategy and judge its psychological costs. The association’s ethics code, while condemning a list of coercive techniques adopted in the Bush administration’s antiterrorism campaign, has allowed some consultation “for national security-related purposes.”

The referendum, first posted on the Internet as a petition in May, prohibits psychologists from working in settings where “persons are held outside of, or in violation of, either International Law (e.g., the U.N. Convention Against Torture and the Geneva Conventions) or the U.S. Constitution, where appropriate,” unless they represent a detainee or an independent third party. The association’s bylaws require that it institute the policy at the next annual meeting, in August 2009.

“The good part of this is that the membership has spoken, the process worked, and we’re going to follow it,” said Alan E. Kazdin, the association’s president and a psychologist at Yale University. “Will everyone be happy? Well, it’s a typical human enterprise, and there are nuanced positions on both sides. So, we’ll see.”