[guided]The purpose of this step is to turn the geometric diameter condition into a maximum-principle statement. The function
\begin{align*}
u:M &\to [0,\infty), & x &\mapsto r_p(x)+r_q(x)-D
\end{align*}
measures the excess in the triangle inequality for the triple $(p,x,q)$. Because $d_g(p,q)=D$, the triangle inequality gives
\begin{align*}
u(x)=r_p(x)+r_q(x)-D\geq 0.
\end{align*}
To prove rigidity, we want to show that this excess is always zero.
We now compute the sign of $\Delta u$. On the set where both distance functions are smooth, define the maps
\begin{align*}
a:M\setminus\{p\} &\to (0,\pi], & x &\mapsto \sqrt{k}\,r_p(x),\\
b:M\setminus\{q\} &\to (0,\pi], & x &\mapsto \sqrt{k}\,r_q(x).
\end{align*}
The diameter bound gives $r_p(x)\leq D$ and $r_q(x)\leq D$, while $x \neq p,q$ gives $r_p(x)>0$ and $r_q(x)>0$. Hence
\begin{align*}
0<a(x)<\pi, \qquad 0<b(x)<\pi.
\end{align*}
The triangle inequality gives
\begin{align*}
a(x)+b(x)=\sqrt{k}\,(r_p(x)+r_q(x))\geq \sqrt{k}\,D=\pi.
\end{align*}
Since each of $a(x)$ and $b(x)$ is at most $\pi$, we also have $a(x)+b(x)\leq 2\pi$. Therefore
\begin{align*}
\sin(a(x)+b(x))\leq 0.
\end{align*}
Because $\sin a(x)>0$ and $\sin b(x)>0$, the trigonometric identity
\begin{align*}
\cot a+\cot b=\frac{\sin(a+b)}{\sin a\,\sin b}
\end{align*}
gives
\begin{align*}
\cot a(x)+\cot b(x)\leq 0.
\end{align*}
Now apply the [Laplacian comparison theorem for distance functions](/page/Laplacian%20Comparison%20Theorem) under the Ricci lower bound $\operatorname{Ric}_g\geq (n-1)k\,g$. The theorem applies to $r_p$ and $r_q$ because $(M,g)$ is complete and has the stated Ricci curvature lower bound. It gives, in the barrier sense and classically away from the cut loci,
\begin{align*}
\Delta r_p(x) &\leq (n-1)\sqrt{k}\,\cot(\sqrt{k}\,r_p(x)),\\
\Delta r_q(x) &\leq (n-1)\sqrt{k}\,\cot(\sqrt{k}\,r_q(x)).
\end{align*}
Adding these inequalities yields
\begin{align*}
\Delta u(x)
&=\Delta r_p(x)+\Delta r_q(x)\\
&\leq (n-1)\sqrt{k}\left(\cot a(x)+\cot b(x)\right)\\
&\leq 0.
\end{align*}
Thus the triangle-excess function $u$ is superharmonic in the barrier sense on $\Omega=M\setminus\{p,q\}$. This is the key analytic input: a non-negative superharmonic function that attains an interior minimum must be constant.[/guided]