Powerful neutral beams used in many present-day magnetic fusion devices to heat the plasma to high temperatures must pass a region of finite background pressure where the magnetic stray field is rather high. Reionization of neutral beam particles and their subsequent deflection onto walls may lead to serious power loadings if no proper protection is provided. The simulation of this problem for the neutral beam injection system of the ASDEX-Upgrade tokamak is examined. The magnetic field distribution and the particle trajectories are calculated in full three-dimensional geometry. The statistical methods applied to simulate the ∼106 beam particles necessary to obtain a reliable power density distribution on the various surfaces of the duct region are described in some detail. Results are given for different magnetic field configurations of the tokamak. Because of the focusing effect of the strongly varying magnetic field, power densities in excess of 2 MW/m2 are found in extreme cases. Additional large area shieldings are installed to protect the most exposed regions of the entrance port of the vessel.