Abstract. In the first part of the paper, we develop a theory of crossed products of a C˚-algebra A by an arbitrary (not necessarily extendible) endomorphism α : A Ñ A. We consider relative crossed products C˚pA, α; Jq where J is an ideal in A, and describe up to Morita-Rieffel equivalence all gauge-invariant ideals in C˚pA, α; Jq and give six term exact sequences determining their K-theory. We also obtain certain criteria implying that all ideals in C˚pA, α; Jq are gauge-invariant, and that C˚pA, α; Jq is purely infinite.In the second part, we consider a situation where A is a C 0 pXq-algebra and α is such that αpf aq " Φpf qαpaq, a P A, f P C 0 pXq where Φ is an endomorphism of C 0 pXq. Pictorially speaking, α is a mixture of a topological dynamical system pX, ϕq dual to pC 0 pXq, Φq and a continuous field of homomorphisms α x between the fibers Apxq, x P X, of the corresponding C˚-bundle.For systems described above, we establish efficient conditions for the uniqueness property, gauge-invariance of all ideals, and pure infiniteness of C˚pA, α; Jq. We apply these results to the case when X " PrimpAq is a Hausdorff space. In particular, if the associated C˚-bundle is trivial, we obtain formulas for K-groups of all ideals in C˚pA, α; Jq. In this way, we constitute a large class of crossed products whose ideal structure and K-theory is completely described in terms of pX, ϕ, tα x u xPX ; Y q where Y is a closed subset of X.Introduction.