Energy spectra of ions and fast electrons accelerated by a channeling laser pulse in near-critical plasma are studied using three-dimensional (3D) Particle-In-Cell simulations. The realistic 3D geometry of the simulations allows us to obtain not only the shape of the spectra, but also the absolute numbers of accelerated particles. It is shown that ions are accelerated by a collisionless radial expansion of the channel and have nonthermal energy spectra. The electron energy spectra instead are Boltzmann-like. The effective temperature Teff scales as I1/2. The form of electron spectra and Teff depends also on the length of the plasma channel. The major mechanism of electron acceleration in relativistic channels is identified. Electrons make transverse betatron oscillations in the self-generated static electric and magnetic fields. When the betatron frequency coincides with the laser frequency as witnessed by the relativistic electron, a resonance occurs, leading to an effective energy exchange between the laser and electron. This is the inverse free-electron laser mechanism. Electrons are accelerated at the betatron resonance when the laser power overcomes significantly the critical power for self-focusing.