Context : Anomalous X-ray pulsars ( AXPs ) and soft gamma-ray repeaters ( SGRs ) constitute a special population of young neutron stars , which are thought to be magnetars , i.e. , neutron stars with super-strong magnetic fields ( 10 ^ { 14 } -10 ^ { 15 } ) G . Aims : Assuming that AXPs and SGRs accrete matter from a fallback disk , we attempt to explain the energy-dependent pulse profiles exhibited by the AXP 4U 0142+61 , as well as its phase-dependent energy spectra . Methods : We test the hypothesis that not only the X-ray spectra , but also the energy-dependent pulse profiles of 4U 0142+61 are produced by accretion along dipole magnetic field lines of strength 10 ^ { 12 } -10 ^ { 13 } G at the neutron-star surface . Results : In the fallback disk model , the Thomson optical depth along the accretion funnel is significant and bulk-motion Comptonization operates efficiently . This is enhanced by resonant cyclotron scattering . The thus scattered photons escape mainly sideways and produce a fan beam , which is detected as a main pulse up to energies of \sim 160 keV . The approximately isotropic emission from the stellar surface ( soft thermal photons and reflected hard X-ray ones ) is detected as a secondary pulse . This secondary pulse shows a bump at an energy of about 60 keV , which may be interpreted as resonant cyclotron scattering of fan-beam photons at the neutron-star surface . This implies a dipole magnetic field strength B \approx 7 \times 10 ^ { 12 } ( 1 + z ) G , where z is the gravitational redshift . Conclusions : Our model explains not only the soft and hard X-ray spectra of the AXP 4U 0142+61 , but also its energy dependent pulse profiles . If our interpretation of the energy dependence of the secondary pulse is correct , the surface dipole magnetic field strength is comparable to that of X-ray pulsars . Much like our Sun , the surface multipole magnetic field strength may be two orders of magnitude larger , thus allowing for energetic bursts to occur . The accretion process is mediated by the dipole field and is not interfering at all with the multipole field .