Spontaneous imbibition is an important mechanism of oil recovery in naturally fractured reservoirs. The flow of oil from matrix system to fracture system will generally involve both cocurrent and countercurrent imbibition. Understanding the mechanism of cocurrent and countercurrent imbibition is essential in oil recovery from fractured reservoirs. In the previous work, we focused on the purely cocurrent imbibition (Meng et al. 2015), and we now focus on the combination of cocurrent and countercurrent imbibition. In this paper, a new mathematical model, which could be used to simulate the combination of cocurrent and countercurrent imbibition with the two-ends-open oil/water (TEO-OW) boundary condition, is developed. In the TEO-OW boundary condition, one end face of the core is exposed to water and the other is exposed to oil. Experiments of spontaneous imbibition with the TEO-OW boundary condition were performed. Air and oil were used as the nonwetting phase in the experiments to obtain different viscosities ranging from 0.018 to 103.4 cp. The porous media used in the experiments were packed with glass beads or quartz sand, both of which were strongly water-wet. The geometry of the glass beads is spherical and the particle-size distribution is narrow, and the geometry of the quartz sand is irregular and the particle-size distribution is wide. Both oil production from inlet and outlet faces and the advancing distance of the imbibition front were measured against time. The experimental results showed that the largest fraction of the oil/gas production occurred by cocurrent imbibition in both glass-bead packs and quartz sandpacks. In addition, for glass-bead packs, very little of the oil/gas was produced by countercurrent imbibition, and it has almost no change with the increase in oil/gas viscosity. For quartz sandpacks, much more oil/gas was produced by countercurrent imbibition, and it increases noticeably with the increase in oil/gas viscosity (but is still much smaller than cocurrent imbibition). The total oil/gas recovery for glass-bead packs is high and has almost no change with the increase in oil/gas viscosity. In contrast, the total oil/gas recovery for quartz sandpacks is lower and decreases noticeably with the increase in oil/gas viscosity. The relative permeability to water and oil could be obtained by fitting the simulated results with the experimental results. The fitting results show that the relative permeability to water behind the imbibition front decreases with the increase in oil viscosity and the relative permeability to oil for countercurrent imbibition increases with the increase in oil viscosity.