To compensate for bias field inhomogeneity and reduce noise, we incorporate domain-based knowledge and spatial information into a brain segmentation algorithm by proposing a new multi-layer Hidden Markov model. Brain tissues include Gray Matter (GM), White Matter (WM), and Cerebrospinal Fluid (CSF). A typical slice of a brain image either contains GM, GM–WM or GM–WM–CSF. Therefore, we classify the slices into three classes by employing a 1-D Hidden Markov model in the first layer of our method. Corresponding to a class in the first layer, we use another 1-D Hidden Markov model for segmentation of the slices in the second layer. A 2-D slice is converted into a vector by concatenation of the individual rows. Then, it is segmented by a second layer model. We extensively evaluated our method using three public datasets including 5492 images. Our method proves the significant potential of the proposed multi-layer Hidden Markov model for segmentation of 3-D medical image in the presence of noise and field inhomogeneity. Regarding the IBSR_18 datasets, the proposed method improved the results of segmentation of White Matter and Gray Matter by 0.026 and 0.04, respectively, using Dice coefficient index.