A three-dimensional time-dependent, numerical magnetohydrodynamic (MHD) model is used to investigate the propagation of coronal mass ejections (CMEs) in the nonhomogenous background solar wind flow. On the basis of the observations of the solar magnetic field and K-coronal brightness, the self-consistent structure on the source surface of 2.5 Rs is established with the help of MHD equations. Using the self-consistent source surface structures as initial-boundary conditions, we develop a three-dimensional MHD regional combination numerical model code to obtain the background solar wind from the source surface of 2.5 Rs to the Earth’s orbit (215 Rs) and beyond. This model considers solar rotation and volumetric heating. Time-dependent variations of the pressure and velocity configured from a CME model at the inner boundary are applied to generate transient structures. The dynamical interaction of a CME with the background solar wind flow between 2.5 and 215 Rs (1 AU) is then investigated. We have chosen the well-defined halo-CME event of 6–12 January 1997 as a test case. Because detailed observations of this disturbance at 1 AU (by WIND spacecraft) are available, this event gives us an excellent opportunity to verify our MHD methodology and to learn about the physical processes of the Sun-Earth connection. In this study, we find that this three-dimensional MHD model, with the self-consistent structures on the source surface as input, provides a relatively satisfactory comparison with the WIND spacecraft observations.