The inversion of magnetic data is inherently non- unique with respect to the distance between the source and observation locations. This manifests itself as an ambiguity in the source depth when surface data are inverted and as an ambiguity in the distance between the source and boreholes if borehole data are inverted. Joint inversion of surface and borehole data can help to reduce this nonuniqueness. To achieve this, we develop an algorithm for inverting data sets that have arbitrary observation locations in boreholes and above the surface. The algorithm depends upon weighting functions that counteract the geometric decay of magnetic kernels with distance from the observer. We apply these weighting functions to the inversion of three-component magnetic data collected in boreholes and then to the joint inversion of surface and borehole data. Both synthetic and field data sets are used to illustrate the new inversion algorithm. When borehole data are inverted directly, three-component data are far more useful in constructing good susceptibility models than are single-component data. However, either can be used effectively in a joint inversion with surface data to produce models that are superior to those obtained by inversion of surface data alone.