Identification of the anterior and posterior commissure is crucial in stereotactic and functional neurosurgery, human brain mapping, and medical image processing. We present a learning-based algorithm to automatically and rapidly localize these landmarks using random forests regression. Given a point in the image, we extract a set of multi-scale long-range textural features, and associate a probability for this point to be the landmark. We build random forests models to learn the relationship between the value of these features and the probability of a point to be a landmark point. Three-stage coarse-to-fine models are trained for AC and PC separately using down-sampled by 4, down-sampled by 2, and the original images. Testing is performed in a hierarchical approach to first obtain a rough estimation at the coarse level and then fine-tune the landmark position. We extensively evaluate our method in a leave-one-out fashion using a large dataset of 100 T1-weighted images. We also compare our method to the state-of-art AC/PC detection methods including an atlas-based approach with six well-established nonrigid registration algorithms and a publicly available implementation of a model-based approach. Our method results in an overall error of 0.84±0.41mm for AC, 0.83±0.36mm for PC and a maximum error of 2.04mm; it performs significantly better than the model-based AC/PC detection method we compare it to and better than three of the nonrigid registration methods. It is much faster than nonrigid registration methods.