Magnetic billiards in a convex domain with smooth boundary on a constant-curvature surface in a constant magnetic feld is considered in this paper. The question of the existence of an integral of motion which is a polynomial in the components of the velocity is investigated. It is shown that if such an integral exists, then the boundary of the domain defnes a non-singular algebraic curve in C3. It is also shown that for a domain other than a geodesic disk, magnetic billiards does not admit a polynomial integral for all but perhaps fnitely many values of the magnitude of the magnetic feld. To prove our main theorems a new dynamical system, outer magnetic billiards , on a constant-curvature surface is introduced, a system dual to magnetic billiards. By passing to this dynamical system one can apply methods of algebraic geometry to magnetic billiards.