Let $V$ be a finite-dimensional vector space over $\mathbb{C}$ with $\dim V= n $ and let $T \in L(V)$.
Lemma $1$.
Let $V = V_1 \oplus \cdots \oplus V_k$ be the decomposition of $V$ into $T$-invariant subspaces with $T_j := T|_{V_j} \in L(V_j)$. Then the characteristic polynomial of $T$ is a product of characteristic polynomials of $T_j$, i.e.
$$p_T = p_{T_1}\cdots p_{T_k}$$
Proof.
Pick a basis $B$ for $V$ of the form $$B = (\text{basis for }V_1, \ldots, \text{basis for }V_k)$$
The matrix of $T$, and hence also $T - \lambda I$, w.r.t. $B$ is block-diagonal so the claim follows by taking the determinant.
Lemma $2$.
Let $G(\lambda) = \ker (T - \lambda I)^n$ be the generalized eigenspace and set $d = \dim G(\lambda)$. The characteristic polynomial of $T$ restricted to $G(\lambda)$ is $$p_{T|_{G(\lambda)}}(x) = (x - \lambda I)^{d}$$
Proof.
The polynomial $(x-\lambda)^n$ annihilates $T|_{G(\lambda)}$ so $\emptyset \ne \sigma\left(T|_{G(\lambda)}\right) \subseteq \{\text{zeroes of } (x-\lambda)^n\} = \{\lambda\}$. Hence $p_{T|_{G(\lambda)}} = (x - \lambda)^{d}$.
Lemma $3$.
We have $$V = \ker (T - \lambda I)^n \oplus \operatorname{Im}(T - \lambda I)^n = G(\lambda) \oplus \operatorname{Im}(T - \lambda I)^n$$
Proof.
Recall that for every $v \in V$ exists a unique monic polynomial $p_v \in \mathbb{C}[x]$ of minimal degree such that $p_v(T)v = 0$. Since the minimal polynomial $m_T$ annihilates $T$, it follows that $m_T(T)v = 0$ so we have $p_v\mid m_T$ and hence $\deg p_v \le \deg m_T \le n$.
Notice that $\ker (T - \lambda I)^n \cap \operatorname{Im}(T - \lambda I)^n = \{0\}$. Indeed, if $y \in \ker (T - \lambda I)^n \cap \operatorname{Im}(T - \lambda I)^n$ then $\exists x \in V$ such that $y = (T - \lambda I)^{n}x$. We have $(T - \lambda I)^ny = (T - \lambda I)^{2n}x = 0$ so $p_x \mid (x - \lambda)^{2n}$. Therefore $y = (T - \lambda I)^{n}x = 0$.
Rank-nullity theorem now implies $V = \ker (T - \lambda I)^n \oplus \operatorname{Im}(T - \lambda I)^n$.
Now we are ready to prove our result. Notice that $\lambda$ cannot be an eigenvalue of $T|_{\operatorname{Im}(T - \lambda I)^n}$. Indeed, if there exists an eigenvector $y = (T - \lambda I)^n$, then $(T - \lambda I)y = (T - \lambda I)^{n+1}x = 0$ which implies $y = (T - \lambda I)^{n}x = 0$.
By Lemmas $1$, $2$ and $3$ we have $$p_T(x) = p_{G(\lambda)}(x)p_{T|_{\operatorname{Im}(T - \lambda I)^n}}(x) = (x - \lambda)^d p_{T|_{\operatorname{Im}(T - \lambda I)^n}}(x)$$
Notice that the factors are relatively prime because $\lambda$ is not a root of $p_{T|_{\operatorname{Im}(T - \lambda I)^n}}$. Uniqueness of factorization in $\mathbb{C}[x]$ now implies $$d = \text{algebraic multiplicity of }\lambda$$