We propose an extension of the Schrödinger equation for a quantum system interacting with environment. This extension describes dynamics of a collection of auxiliary wavefunctions organized as a matrix m, from which the system density matrix can be reconstructed as ρ̂=mm(†). We formulate a compatibility condition, which ensures that the reconstructed density satisfies a given quantum master equation for the system density. The resulting non-stochastic evolution equation preserves positive-definiteness of the system density and is applicable to both Markovian and non-Markovian system-bath treatments. Our formalism also resolves a long-standing problem of energy loss in the time-dependent variational principle applied to mixed states of closed systems.