The floating wire technique was applied to characterize the focusing properties of the D2 spectrometer magnet to be used in the ANKE installation of the COSY Jülich accelerator facility. Trajectories corresponding to 140–600 MeV/c ejectiles emerging from a target in front of the rectangular-type D2 magnet were measured in order to determine the location of foci where detectors for the physics experiments were to be placed. The focus for trajectories of the same momentum was localized by varying the trajectory start angle at the target. To overcome the problem of instability, which arises when the pulley has to be located behind the focus, an unbalanced pulley was used. Other improvements include methodological features such as the particular design of our air-bearing pulley enabling a “freezing-in” of the wire movement and therefore yielding a very high accuracy of the wire position measurement, the use of a 40 μm gold-plated tungsten wire best fulfilling the mechanical and electrical requirements, a fast-regulating power supply in combination with an absolutely calibrated current meter, and the excellent accuracy of modern surveying instrumentation. An overall momentum accuracy of Δp/p⩽10−3 and a position accuracy of the trajectories of ±1 mm in the vicinity of the foci have been demonstrated. The precision and accuracy of the floating-wire measurements are discussed and compared with ray-tracing calculations based on measured and calculated field maps.