The nature of the magnetic ground state near the insulator-metal transition (IMT) in La(1-x)Ba(x)CoO3 was investigated via neutron scattering. Below the critical concentration, x(c)∼0.22, a commensurate antiferromagnetic (AFM) phase appears initially. Upon approaching x(c), the AFM component weakens and a ferromagnetic (FM) ordered phase sets in while in the rhombohedral lattice. At x(c), a spin flip to a new FM structure occurs at the same time as the crystal symmetry transforms to orthorhombic (Pnma). The Pnma phase may be the driving force for the IMT.