[proofplan]
We prove both inclusions. Ground-model ordinals remain ordinals because $M \subseteq M[G]$ and forcing extensions of transitive models do not change the membership relation on old sets. For the converse, we take an ordinal $\alpha \in M[G]$, choose a $\mathbb{P}$-name in $M$ whose interpretation by $G$ is $\alpha$, and use a rank induction to bound the interpreted set by the syntactic rank of the name. Since an ordinal has rank equal to itself, this places $\alpha$ below a ground-model ordinal, hence inside $M$ by transitivity.
[/proofplan]
[step:Show that every ground-model ordinal remains an ordinal in the extension]
Let $\xi \in \operatorname{Ord}^{M}$. Since $M \subseteq M[G]$, the set $\xi$ belongs to $M[G]$. We use the forcing-extension construction theorem for transitive models, namely the standard result asserting transitivity of the generic extension and preservation of the old membership relation. Its hypotheses apply here because $M$ is transitive, $\mathbb P \in M$ is the forcing notion, and $G \subseteq \mathbb P$ is $M$-generic. The theorem states that $M[G]$ is transitive and that the membership relation on old sets is the ambient membership relation restricted to those sets. Thus, for all $a,b \in M$, one has $a \in b$ in $M$ iff $a \in b$ in $M[G]$.
Because $M$ is transitive, every element of $\xi$ belongs to $M$, and the same membership structure on $\xi$ is seen in the transitive model $M[G]$. Thus $\xi$ is still transitive and well-ordered by $\in$ in $M[G]$. Therefore $\xi \in \operatorname{Ord}^{M[G]}$, so
\begin{align*}
\operatorname{Ord}^{M} \subseteq \operatorname{Ord}^{M[G]}.
\end{align*}
[/step]
[step:Bound the rank of an interpreted name by the rank of the name]
Let $\tau \in M$ be a $\mathbb{P}$-name, meaning a hereditary collection of pairs $(\sigma,p)$ with $\sigma$ again a $\mathbb{P}$-name and $p \in \mathbb P$. Define the $M$-rank of $\tau$, denoted $\operatorname{rank}^{M}(\tau)$, to be the ordinal computed in $M$ by the recursive rule
\begin{align*}
\operatorname{rank}^{M}(\tau)=\sup \{\operatorname{rank}^{M}(\sigma)+1 : \exists p \in \mathbb{P}\, ((\sigma,p) \in \tau)\}.
\end{align*}
Since $M \models \mathrm{ZFC}$, this rank is an ordinal of $M$. Because $M$ is transitive and the recursion defining name rank uses only membership among names already in $M$, this ordinal agrees with the ambient recursive rank of the same name. For any set $y \in M[G]$, write $\operatorname{rank}(y)$ for the ordinary von Neumann rank of $y$ computed in the transitive model $M[G]$, equivalently the ambient rank of $y$ in the surrounding universe.
Here $\tau_G$ denotes the name evaluation of $\tau$ by $G$, namely the set obtained recursively by keeping exactly the interpretations $\sigma_G$ for pairs $(\sigma,p) \in \tau$ with $p \in G$. We claim that for every $\mathbb{P}$-name $\tau \in M$,
\begin{align*}
\operatorname{rank}(\tau_G) \leq \operatorname{rank}^{M}(\tau).
\end{align*}
[claim:Evaluation does not increase rank beyond the name rank]
For every $\mathbb{P}$-name $\tau \in M$, the interpreted set $\tau_G$ satisfies
\begin{align*}
\operatorname{rank}(\tau_G) \leq \operatorname{rank}^{M}(\tau).
\end{align*}
[/claim]
[proof]
We prove the claim by induction on the ordinal $\operatorname{rank}^{M}(\tau)$. Fix a $\mathbb{P}$-name $\tau \in M$, and assume the assertion has already been proved for every $\mathbb{P}$-name $\sigma \in M$ with
\begin{align*}
\operatorname{rank}^{M}(\sigma) < \operatorname{rank}^{M}(\tau).
\end{align*}
By definition of name evaluation,
\begin{align*}
\tau_G=\{\sigma_G : \exists p \in G\, ((\sigma,p) \in \tau)\}.
\end{align*}
Let $x \in \tau_G$. Then there exist a $\mathbb{P}$-name $\sigma \in M$ and a condition $p \in G$ such that $(\sigma,p) \in \tau$ and $x=\sigma_G$. From the definition of $\operatorname{rank}^{M}(\tau)$, this implies
\begin{align*}
\operatorname{rank}^{M}(\sigma) + 1 \leq \operatorname{rank}^{M}(\tau),
\end{align*}
and hence
\begin{align*}
\operatorname{rank}^{M}(\sigma) < \operatorname{rank}^{M}(\tau).
\end{align*}
The induction hypothesis gives
\begin{align*}
\operatorname{rank}(x)=\operatorname{rank}(\sigma_G)\leq\operatorname{rank}^{M}(\sigma)<\operatorname{rank}^{M}(\tau).
\end{align*}
Since this holds for every $x \in \tau_G$, the definition of rank gives
\begin{align*}
\operatorname{rank}(\tau_G)=\sup\{\operatorname{rank}(x)+1 : x \in \tau_G\}\leq\operatorname{rank}^{M}(\tau).
\end{align*}
This proves the claim.
[/proof]
[guided]
The point of this step is to make precise the idea that evaluating a name cannot create sets of rank higher than the syntactic rank already present in the name. Let $\tau \in M$ be a $\mathbb{P}$-name. A $\mathbb P$-name is built hereditarily from pairs $(\sigma,p)$, where $\sigma$ is again a $\mathbb P$-name and $p \in \mathbb P$. Its $M$-rank is the ordinal
\begin{align*}
\operatorname{rank}^{M}(\tau)=\sup \{\operatorname{rank}^{M}(\sigma)+1 : \exists p \in \mathbb{P}\, ((\sigma,p) \in \tau)\}.
\end{align*}
This definition is made inside $M$, and since $M$ satisfies $\mathrm{ZFC}$, the value is an ordinal of $M$. Because $M$ is transitive and the recursion only inspects the membership structure of names belonging to $M$, the ordinal computed by $M$ is the same ordinal obtained by carrying out the same recursion in the ambient universe. For any set $y \in M[G]$, the notation $\operatorname{rank}(y)$ denotes the ordinary von Neumann rank of $y$ computed in the transitive model $M[G]$, equivalently the ambient rank of $y$ in the surrounding universe.
We prove by induction on $\operatorname{rank}^{M}(\tau)$ that
\begin{align*}
\operatorname{rank}(\tau_G) \leq \operatorname{rank}^{M}(\tau).
\end{align*}
Assume the assertion is known for all names $\sigma \in M$ of strictly smaller $M$-rank than $\tau$. The name evaluation of $\tau$ by $G$ is the recursively defined interpretation
\begin{align*}
\tau_G=\{\sigma_G : \exists p \in G\, ((\sigma,p) \in \tau)\}.
\end{align*}
Thus every element $x \in \tau_G$ has the form $x=\sigma_G$ for some pair $(\sigma,p) \in \tau$ with $p \in G$.
For such a $\sigma$, the definition of the name rank gives
\begin{align*}
\operatorname{rank}^{M}(\sigma)+1 \leq \operatorname{rank}^{M}(\tau),
\end{align*}
so $\sigma$ has strictly smaller $M$-rank than $\tau$. The induction hypothesis applies to $\sigma$ and yields
\begin{align*}
\operatorname{rank}(x)=\operatorname{rank}(\sigma_G)\leq\operatorname{rank}^{M}(\sigma)<\operatorname{rank}^{M}(\tau).
\end{align*}
Since every element of $\tau_G$ has rank below $\operatorname{rank}^{M}(\tau)$, taking the supremum in the definition of rank gives
\begin{align*}
\operatorname{rank}(\tau_G)=\sup\{\operatorname{rank}(x)+1 : x \in \tau_G\}\leq\operatorname{rank}^{M}(\tau).
\end{align*}
This proves the rank bound.
[/guided]
[/step]
[step:Use the rank bound to show that no new ordinal appears]
Let $\alpha \in \operatorname{Ord}^{M[G]}$. By definition of the forcing extension, there exists a $\mathbb{P}$-name $\tau \in M$ such that
\begin{align*}
\tau_G = \alpha.
\end{align*}
Let $\beta := \operatorname{rank}^{M}(\tau)$. By the previous step,
\begin{align*}
\operatorname{rank}(\alpha) \leq \beta.
\end{align*}
Since $\alpha$ is an ordinal, its rank is itself:
\begin{align*}
\operatorname{rank}(\alpha)=\alpha.
\end{align*}
Therefore $\alpha \leq \beta$.
Because $\beta \in \operatorname{Ord}^{M}$ and $M \models \mathrm{ZFC}$, the successor ordinal $\beta+1$ belongs to $M$. Since $M$ is transitive, every element of $\beta+1$ belongs to $M$. The inequality $\alpha \leq \beta$ means exactly that $\alpha \in \beta+1$, and hence $\alpha \in M$. Since $M$ is transitive, ordinalhood is absolute between $M$ and the ambient universe for elements of $M$; therefore $M$ also regards $\alpha$ as an ordinal. Thus
\begin{align*}
\operatorname{Ord}^{M[G]} \subseteq \operatorname{Ord}^{M}.
\end{align*}
[/step]
[step:Combine the two inclusions]
The first step proved
\begin{align*}
\operatorname{Ord}^{M} \subseteq \operatorname{Ord}^{M[G]}.
\end{align*}
The previous step proved
\begin{align*}
\operatorname{Ord}^{M[G]} \subseteq \operatorname{Ord}^{M}.
\end{align*}
Therefore
\begin{align*}
\operatorname{Ord}^{M[G]}=\operatorname{Ord}^{M}.
\end{align*}
This completes the proof.
[/step]