This paper deals with subspace-based target detection in hyperspectral images. Specifically, it focuses on a general detection scheme where, first, background is suppressed through orthogonal-subspace projection and then target detection is accomplished. An adequate estimation of the background subspace is essential to a successful outcome. The background subspace has been typically estimated globally. However, global approaches may be ineffective for small-target-detection applications since they tend to overestimate the background interference affecting a given target. This may result in a low target residual energy after background suppression that is detrimental to detection performance. In this paper, we propose a novel and fully automatic algorithm for local background-subspace estimation (LBSE). Local background has typically a lower inherent complexity than that of global background. By estimating the background subspace over a local neighborhood of the test pixel, the resulting background-subspace dimension is expected to be low, thus resulting in a higher target residual energy after suppression which benefits the detection performance. Specifically, the proposed LBSE acts on a per-pixel basis, thus adaptively tailoring the estimated basis to the local complexity of background. Both simulated and real hyperspectral data are employed to investigate the detection-performance improvements offered by LBSE with respect to both global and local methodologies previously presented.