Target detection is aimed at detecting and identifying target pixels based on specific spectral signatures, and is of great interest in hyperspectral image (HSI) processing. Target detection can be considered as essentially a binary classification. Random forests have been effectively applied to the classification of HSI data. However, random forests need a huge amount of labeled data to achieve a good performance, which can be difficult to obtain in target detection. In this paper, we propose an efficient metric learning detector based on random forests, named the random forest metric learning (RFML) algorithm, which combines semimultiple metrics with random forests to better separate the desired targets and background. The experimental results demonstrate that the proposed method outperforms both the state-of-the-art target detection algorithms and the other classical metric learning methods.Index Terms-Hyperspectral image (HSI), metric learning, random forests, target detection.