This paper deals with a nonlinear surface and interface sloshing in layered two immiscible fluids of different desities. Scientific interest in surface and interface sloshing includes the need to quantify allowance loads on separators or agitators in chemical plants and so on. We propose the analytical method for nonlinear sloshing in this problem by using Hamiltonian formulation. In theoretical analysis, the governing equations and canonical form (Hamiltonian equations) of a system of two fluids with a dynamic free surface and interface are given by applying Hamilton's principle. Moreover, the nonlinear ordinary differential system which governs liquid surface and interfacial wave motions is derived by using Dirichlet-Neumann operators and the generalized Fourier series expansion. Solving these ordinary differential system yields the time histories and the transitions of surface and interfacial wave motions in a rectangular tank. The validly of the theoretical analysis is verified through the experiments.