As sparse representation gradually obtains better and better results in the analysis of hyperspectral imagery and sparsity-based algorithms are becoming more and more popular, especially in target detection. However, these methods mostly assume an absolute equal contribution by all neighboring pixels while detecting the central pixel. There is no doubt that this approach is unsuitable for pixels located in heterogeneous areas. In this letter, to address this problem, spatially adaptive sparse representation for target detection in hyperspectral images (HSIs) is proposed. Neighboring spatial information is utilized by considering the different contributions of the distinct neighborhood pixels. The different weights are determined according to the similarity between the neighboring pixels and the central test pixel. The proposed algorithm was tested on two HSIs and demonstrated outstanding detection performance when compared with other commonly used detectors.