The energy exchange mechanism for a rectilinear relativistic electron beam (REB) with rotating H//1 fields in an inhomogeneous magnetic field is investigated when there is a substantial magnetostatic conversion of the drift energy of electrons that have been subjected to an rf field. With a magnetic field of optimum shape there is an almost total transfer of REB energy to the electromagnetic field in generating and amplifying systems.