A number of surgical procedures are planned and executed based on medical images. Typically, x-ray computed tomography (CT) and magnetic resonance (MR) images are acquired preoperatively for diagnosis and surgical planning. In the operating room, execution of the surgical plan becomes feasible due to registration between preoperative images and surgical space where patient anatomy lies. In this paper, we present a new automatic algorithm where we use ultrasound (US) 2D B-mode images to register the preoperative MR image coordinate system with the surgical space which in our experiments is represented by the reference coordinate system of a DC magnetic position sensor. The position sensor is also used for tracking the position and orientation of the US images. Furthermore, we simulated patient anatomy by using custom-built phantoms. Our registration algorithm is a hybrid between fiducial- based and image-based registration algorithms. Initially, we perform a fiducial-based rigid-body registration between MR and position sensor space. Then, by changing various parameters of the rigid-body fiducial-based transformation, we produce an MR-sensor misregistration in order to simulate potential movements of the skin fiducials and/or the organs. The perturbed transformation serves as the initial estimate for the image-based registration algorithm, which uses normalized mutual information as a similarity measure, where one or more US images of the phantom are automatically matched with the MR image data set. By using the fiducial- based registration as the gold standard, we could compute the accuracy of the image-based registration algorithm in registering MR and sensor spaces. The registration error varied depending on the number of 2D US images used for registration. A good compromise between accuracy and computation time was the use of 3 US slices. In this case, the registration error had a mean value of 1.88 mm and standard deviation of 0.42 mm, whereas the required computation time was approximately 52 sec. Subsampling the US data by a factor of 4 X 4 and reducing the number of histogram bins to 128 reduced the computation time to approximately 6 sec. with a small increase in the registration error.