We discover a transition from extended to localized quasi-modes for light in a gas of immobile two-level atoms in a magnetic field. The transition takes place either upon increasing the number density of atoms in a strong field or upon increasing the field at a high enough density. It has many characteristic features of a disorder-driven (Anderson) transition but is strongly influenced by near-field interactions between atoms and the anisotropy of the atomic medium induced by the magnetic field.The transition from extended to localized eigenstates upon increasing disorder in a quantum or wave system is called after Philip Anderson who was the first to predict it for electrons in disordered solids [1]. More recently, this transition was studied for various types of quantum particles (cold atoms [2], Bose-Einstein condensates [3]) as well as for classical waves (light [4-6], ultrasound [7,8]). In the most common case of time-reversal symmetric systems invariant under spin rotation Anderson transition takes place for a three-dimensional (3D) disorder only, eigenstates of low-dimensional systems being always localized [9,10]. Anderson localization of light may find applications in the design of future quantuminformation devices [11], miniature lasers [12] and solar cells [13]. However, no undisputable experimental observation of optical Anderson transition in 3D exists to date since alternative explanations were proposed for all published reports of it [14][15][16]. Moreover, we have recently shown that the simplest theoretical model in which light is scattered by point scatterers (atoms) does not predict Anderson localization of light at all [17].In the present Letter we show that an external magnetic field may induce a transition between extended and localized states for light in a gas of cold atoms. Magnetic field is an important and unique means of controlling wave propagation in disordered media. On the one hand, it breaks down the time-reversal invariance leading to a suppression of weak localization in electronic [18] and optical [19] systems and to metal-insulator transitions in topological insulators [20]. On the other hand, by profoundly modifying the scattering properties of individual scatterers the magnetic field can produce an enhancement of the coherent backscattering peak for light scattered by atoms with a degenerate ground state [21,22]. Our work adds a new element in the mosaic of magnetic-field-induced phenomena in disordered systems by demonstrating that the removal of degeneracy of the excited atomic state due to the Zeeman effect and the resulting reduction of the strength of resonant dipole-dipole * Sergey. We consider an ensemble of N 1 identical two-level atoms at random position {r i } inside a spherical volume V of radius R. The resonant frequency ω 0 of atoms defines the natural length scale 1/k 0 = c/ω 0 , where c is the vacuum speed of light. The ground state |g i of an isolated atom i is nondegenerate with the total angular momentum J g = 0, whereas the excited states |e i is three-fo...