We study the problem of perturbations of quasiperiodic motions in the class of locally Hamiltonian systems. By using methods of the KAM-theory, we prove a theorem on the existence of invariant tori of locally Hamiltonian systems close to conditionally integrable systems. On the basis of this theorem, we investigate the bifurcation of a Cantor set of invariant tori in the case where a Liouville-integrable system is perturbed by a locally Hamiltonian vector field and, simultaneously, the symplectic structure of the phase space is deformed.