Let $B_n$ denote the classical braid group on $n$ strands and let the mixed braid group$B_{m,n}$ be the subgroup of $B_{m+n}$ comprising braids for which the first $m$ strands form the identity braid. Let $B_{m,\infty}=\bigcup_nB_{m,n}$. We describe explicit algebraic moves on $B_{m,\infty}$ such that equivalence classes under these moves classify oriented links up to isotopy in a link complement or in a closed, connected, oriented three-manifold. The moves depend on a fixed link representing the manifold in $S^3$. More precisely, for link complements the moves are the two familiar moves of the classical Markov equivalence together with ‘twisted’ conjugation by certain loops $a_i$. This means premultiplication by $a_i^{-1}$ and postmultiplication by a ‘combed’ version of $a_i$. For closed three-manifolds there is an additional set of ‘combed’ band moves that correspond to sliding moves over the surgery link. The main tool in the proofs is the one-move Markov theorem using $L$-moves (adding in-box crossings). The resulting algebraic classification is a direct extension of the classical Markov theorem that classifies links in $S^3$ up to isotopy, and potentially leads to powerful new link invariants, which have been explored in special cases by the first author. It also provides a controlled range of isotopy moves, useful for studying skein modules of three-manifolds.