We present an automatic and unsupervised method for non-rigid registration of 3D magnetic resonance (MR) images with the Stockholm Computerized Brain Atlas (CBA). This method can be used in the context of multimodal medical image registration, fusion and automatic brain segmentation. In these applications anatomical images (MR) are coregistered with low spatial resolution functional imaging modalities (PET and SPECT) and fused with the neurological database of the CBA. The proposed matching method is based on the minimization of a 3D Chamfer distance function between the surface of the brain extracted from the MR image and the CBA brain surface. The surface-to-surface distance function is efficiently calculated by using a precomputed point-to-surface Euclidean distance map. The non-rigid inter-patient transformation of the CBA is modeled by a generalized 3D second order transformation. This transformation is easily differentiable and, as a consequence, fast and efficient minimization methods can be used. First, a quasi-rigid, first order transformation is computed. Then, the matching is improved by introducing the second order coefficients into the transformation. After this global matching, a local adaptation of the CBA is performed by a morphing method. The combination of a second order global transformation with a 3D local morphing allows the user to obtain a registration accuracy of one pixel, i.e. a mean distance between the surface of the brain in the MR image and the CBA of one pixel, which is significantly better than what can be expected from a human operator.