A magnetic field measuring system with two rectangular loops perpendicular to each other is developed and used to detect the total horizontal magnetic field produced by lightning discharges. Two sets of antenna with low gain and high gain are designed separately in order to obtain both small and large signals. The system was tested experimentally in a high-voltage laboratory, and the results show that the system is reliable, and the waveforms detected by the system are very similar to the source current. The corresponding maximum current that can be measured by the system with low gain antenna and high gain antenna locating at a distance of 60 m from a lightning channel, is about 84.4 kA and 37.7 kA, respectively. For artificially triggered lightning flashes the magnetic field waveforms detected at 60 m from the channel reflect quite well the channel base currents. Using Ampere's law of magnetostatics, the inferred currents from the magnetic fields for three artificially triggered lightning return strokes were 39.8 kA, 29.1 kA and 43 kA, respectively, which are close to the directly measured results of 41.6 kA, 29.6 kA and 38 kA at the base of the discharge channel. The system can be a useful tool in the research of close electromagnetic environment of lightning flashes.