This paper considers an uncertain exit time multi-period mean–variance portfolio selection problem with endogenous liabilities in a Markov jump market, where assets and liabilities of the balance sheet are simultaneously optimized. The random returns of assets and liabilities depend on the states of the financial market. By applying the Lagrange duality method, the Khatri–Rao matrix product technique and the dynamic programming approach, the explicit expressions for the mean–variance efficient strategy and efficient frontier are derived. In addition, the optimal balance sheet structures in both cases with and without boundary constraints are studied. Moreover, some degenerate cases are discussed, and some results in the literature are recovered as degenerate cases under our setting. Furthermore, a numerical example based on real data from the Chinese stock market is provided to illustrate the results obtained in this paper, and some interesting findings are presented.