The spontaneous baryogenesis scenario explains how a baryon asymmetry can develop while baryon violating interactions are still in thermal equilibrium. However, generation of the chemical potential from the derivative coupling is dubious since the chemical potential may not appear after the Legendre transformation. The geometric phase (Pancharatnam-Berry phase) results from the geometrical properties of the parameter space of the Hamiltonian, which is calculated from the Berry connection. In this paper, using the formalism of the Berry phase, we show that the chemical potential defined by the Berry connection is consistent with the Legendre transformation. The framework of the Berry phase is useful in explaining the mathematical background of the spontaneous baryogenesis and also in calculating the asymmetry of the nonthermal particle production in time-dependent backgrounds. Using the formalism, we show that the mechanism can be extended to more complex situations. PACS numbers: 98.80Cq 4 See also Appendix B 5 Here, R in U (R) represents arbitrary parameters.