The chiral magnetic effect (CME) refers to charge separation along a strong magnetic field due to imbalanced chirality of quarks in local parity and charge-parity violating domains in quantum chromodynamics. The experimental measurement of the charge separation is made difficult by the presence of a major background from elliptic azimuthal anisotropy. This background and the CME signal have different sensitivities to the spectator and participant planes, and could thus be determined by measurements with respect to these planes. We report such measurements in Au+Au collisions at a nucleon-nucleon center-of-mass energy of 200 GeV at the Relativistic Heavy-Ion Collider. It is found that the charge separation, with the flow background removed, is consistent with zero in peripheral (large impact parameter) collisions. Some indication of finite CME signals is seen in midcentral (intermediate impact parameter) collisions. Significant residual background effects may, however, still be present.