The relation between level crossings, entanglement, and Berry phases is investigated for the Breit-Rabi Hamiltonian of hydrogen and sodium atoms, describing a hyperfine interaction of electron and nuclear spins in a magnetic field. It is shown that the entanglement between nuclear and electron spins is maximum at avoided crossings. An entangled state encircling avoided crossings acquires a marginal Berry phase of a subsystem like an instantaneous eigenstate moving around real crossings accumulates a Berry phase. Especially, the nodal points of a marginal Berry phase correspond to the avoided crossing points.