[step:Critical points of $E$ among endpoint-fixing variations are geodesics]
For Part 2, we characterise the critical points. An endpoint-fixing variation has $H(0, s) = \gamma(0)$ and $H(T, s) = \gamma(T)$ for all $s$, so $Y(0) = Y(T) = 0$ and the boundary term in the first variation formula vanishes. The first variation reduces to
\begin{align*}
\frac{d}{ds} E(\gamma_s)\Big|_{s = 0} = -\int_0^T g\!\left(Y(t), \nabla_t \dot\gamma(t)\right) d\mathcal{L}^1(t).
\end{align*}
$(\Leftarrow)$ If $\gamma$ is a geodesic, $\nabla_t \dot\gamma \equiv 0$ on $[0, T]$, so the integrand vanishes and the first variation is $0$ for every variation. Thus $\gamma$ is a critical point.
$(\Rightarrow)$ Suppose $\gamma$ is a critical point: the first variation vanishes for every endpoint-fixing variation. We claim $\nabla_t \dot\gamma \equiv 0$.
[claim:The vanishing of $\int_0^T g(Y, \nabla_t \dot\gamma) \, d\mathcal{L}^1 = 0$ for all $Y$ vanishing at the endpoints forces $\nabla_t \dot\gamma \equiv 0$]
[proof]
We prove this on each smooth segment $(t_{i-1}, t_i)$ of $\gamma$. Suppose, for contradiction, that $\nabla_t \dot\gamma(t^*) \neq 0$ for some $t^* \in (t_{i-1}, t_i)$. By continuity of $\nabla_t \dot\gamma$ on $(t_{i-1}, t_i)$, there is a closed sub-interval $[a, b] \subset (t_{i-1}, t_i)$ with $t^* \in (a, b)$ on which $\nabla_t \dot\gamma$ is continuous and non-vanishing.
**Construction of the test field.** Let $\eta \in C_c^\infty(0, T)$ be a smooth bump function with $\eta \ge 0$, $\operatorname{supp} \eta \subseteq [a, b]$, and $\eta(t^*) = 1$. Let $P_t : T_{\gamma(t^*)} M \to T_{\gamma(t)} M$ denote parallel transport along $\gamma$ from $\gamma(t^*)$ to $\gamma(t)$. Define
\begin{align*}
Y(t) := \eta(t) \cdot P_t\!\left(\nabla_t \dot\gamma(t^*)\right),
\end{align*}
so $Y$ is smooth along $\gamma$, vanishes outside $[a,b]$, and so vanishes at endpoints and near every breakpoint.
**Sign of the integral.** Parallel transport is an isometry, so the function $t \mapsto g(P_t(\nabla_t \dot\gamma(t^*)), \nabla_t \dot\gamma(t))$ is continuous on $[a, b]$ and equals $|\nabla_t \dot\gamma(t^*)|_g^2 > 0$ at $t = t^*$. By shrinking $[a,b]$ around $t^*$ if necessary, we may assume this inner product remains $\ge \tfrac12 |\nabla_t \dot\gamma(t^*)|_g^2 > 0$ throughout $[a,b]$. Hence
\begin{align*}
\int_0^T g(Y, \nabla_t \dot\gamma) \, d\mathcal{L}^1(t) \ge \frac{1}{2}|\nabla_t \dot\gamma(t^*)|_g^2 \int_a^b \eta\, d\mathcal{L}^1(t) > 0,
\end{align*}
contradicting the vanishing of $\int_0^T g(Y, \nabla_t\dot\gamma)\, d\mathcal{L}^1$ implied by the criticality assumption (since $Y$ vanishes at endpoints and near breakpoints, all boundary and jump terms drop out).
Realise $Y$ as the variational field of $H(t, s) := \exp_{\gamma(t)}(s Y(t))$, well-defined and smooth for $|s|$ small.
Therefore $\nabla_t \dot\gamma \equiv 0$ on every smooth segment of $\gamma$.
**Continuity at breakpoints.** With $\nabla_t \dot\gamma = 0$ on each segment now established, the first variation formula reduces, for any admissible $Y$ with $Y(0) = Y(T) = 0$, to
\begin{align*}
0 = \frac{d}{ds} E(\gamma_s)\Big|_{s=0} = -\sum_{i=1}^{N-1} g\!\left(Y(t_i),\, \dot\gamma(t_i^+) - \dot\gamma(t_i^-)\right).
\end{align*}
For each interior breakpoint $t_i$ choose a smooth $Y$ along $\gamma$ with $Y(t_i) = \dot\gamma(t_i^+) - \dot\gamma(t_i^-)$ and $Y(t_j) = 0$ for $j \ne i$ (constructed by parallel-transporting the jump from $\gamma(t_i)$ along $\gamma$ and multiplying by a bump function supported near $t_i$). The criticality condition gives $|\dot\gamma(t_i^+) - \dot\gamma(t_i^-)|_g^2 = 0$, hence $\dot\gamma(t_i^+) = \dot\gamma(t_i^-)$. So $\dot\gamma$ is continuous at every breakpoint. Combined with $\nabla_t \dot\gamma = 0$ on each segment, the geodesic ODE propagates smoothness across each $t_i$, so $\gamma$ is a smooth geodesic on $[0, T]$.
[/proof]
[/claim]
This proves Part 2: critical points are geodesics, and conversely.
[/step]