An electrochemical cell has been developed for in situ x-ray diffraction from a working electrode under clean conditions equivalent to ultrahigh vacuum conditions of 5 x 10(-10) mbar. The substrate crystals can be prepared ex situ and transferred into the cell under protection of ultrapure water within a few seconds. The oxygen level in the electrolyte is reduced by continuous N(2) flow to less than 0.2% compared to that of a fresh electrolyte. This can be done while rotating the cell by 360 degrees about the surface normal. The electrode potential is accurately measured at the position of the crystal using a Luggin capillary and a standard reference electrode. We demonstrate the performance of our cell by in situ synchrotron x-ray diffraction measurements on ultrathin Co layers electrodeposited on Cu(001) in an aqueous H(2)SO(4)/CoSO(4) solution. (C) 1998 American Institute of Physics.