Lets prove that $A$ and $B$ have at least one common eigenvector. If $x\in \ker(A-\lambda I)$, we have
$$
(AB-BA)x = (A-\lambda I)Bx.
$$
For $x\in \ker (AB-BA)$ this imply $Bx\in \ker(A - \lambda I)$, which means that $\ker(A-\lambda I)$ is an invariant subspace for operator $B$, so there is an eigenvector $y$ of $B$ lying in it.
We win when at least one eigenvector of $A$ or $B$ lying in $\ker(AB-BA)$. Consider the case when all the eigenvectors of $A$ and $B$ are not in $\ker(AB-BA)$. From well-known identity
$$
\dim\ker(AB-BA) = n - \mathrm{rank}\,(AB-BA) = n-1,
$$
so eigenvectors of both $A$ and $B$ lying in the subspace of dimension $1$, which means they have common eigenvector.
Now, lets $v$ be a common eigenvector of $A$ and $B$ in some basis $\{e_1,\dots, e_n\}$. Then in basis $\{v,e_2,\dots, e_n\}$ matrices of $A$ and $B$ become
$$
A = \begin{pmatrix}
\lambda & X \\
0 & A_1
\end{pmatrix}, \quad
B = \begin{pmatrix}
\mu & Y \\
0 & B_1
\end{pmatrix}.
$$
This yields $\mathrm{rank}(A_1B_1-B_1A_1) \leq \mathrm{rank}(AB-BA)$, so we have the same situation for $A_1$ and $B_1$. Repeating this reasoning $n$ times we obtain the upper-triangular forms of $A$ and $B$ in the same basis.