We study integrable and superintegrable systems with magnetic field possessing quadratic integrals of motion on the three-dimensional Euclidean space. In contrast with the case without vector potential, the corresponding integrals may no longer be connected to separation of variables in the Hamilton–Jacobi equation and can have more general leading order terms. We focus on two cases extending the physically relevant cylindrical- and spherical-type integrals. We find three new integrable systems in the generalized cylindrical case but none in the spherical one. We conjecture that this is related to the presence, respectively absence, of maximal abelian Lie subalgebra of the three-dimensional Euclidean algebra generated by first order integrals in the limit of vanishing magnetic field. By investigating superintegrability, we find only one (minimally) superintegrable system among the integrable ones. It does not separate in any orthogonal coordinate system. This system provides a mathematical model of a helical undulator placed in an infinite solenoid.