Controlling magnetism by purely electrical means is a key challenge to better information technology 1 . A variety of material systems, including ferromagnetic (FM) metals2-4, FM semiconductors 5 , multiferroics6-8 and magnetoelectric (ME) materials9,10, have been explored for the electric-field control of magnetism. The recent discovery of two-dimensional (2D) van der Waals magnets11,12 has opened a new door for the electrical control of magnetism at the nanometre scale through a van der Waals heterostructure device platform 13 . Here we demonstrate the control of magnetism in bilayer CrI3, an antiferromagnetic (AFM) semiconductor in its ground state 12 , by the application of small gate voltages in field-effect devices and the detection of magnetization using magnetic circular dichroism (MCD) microscopy. The applied electric field creates an interlayer potential difference, which results in a large linear ME effect, whose sign depends on the interlayer AFM order. We also achieve a complete and reversible electrical switching between the interlayer AFM and FM states in the vicinity of the interlayer spin-flip transition. The effect originates from the electric-field dependence of the interlayer exchange bias.