[step:Reduce the Legendre symbol to a signed product of least residues]Let
\begin{align*}
m:=\frac{p-1}{2}.
\end{align*}
Since $p$ is odd, $m \in \mathbb{N}$. For each $k \in \{1,\dots,m\}$, define $r_k \in \{1,\dots,p-1\}$ to be the least positive residue of $2k$ modulo $p$. Since $1 \leq k \leq m$, we have $2 \leq 2k \leq p-1$, so in fact
\begin{align*}
r_k=2k.
\end{align*}
Define
\begin{align*}
N:=\#\{k \in \{1,\dots,m\}: r_k>p/2\}.
\end{align*}
For each $k \in \{1,\dots,m\}$, define $s_k \in \{1,\dots,m\}$ by
\begin{align*}
s_k=
\begin{cases}
r_k, & r_k<p/2,
\end{align*}
\begin{align*}
p-r_k, & r_k>p/2.
\end{cases}
\end{align*}
The case $r_k=p/2$ cannot occur because $p$ is odd and $r_k$ is an integer.
We claim that the numbers $s_1,\dots,s_m$ are pairwise distinct. If $s_i=s_j$, then from the definition of $s_i$ and $s_j$ we have
\begin{align*}
2i \equiv 2j \pmod{p}
\end{align*}
or
\begin{align*}
2i \equiv -2j \pmod{p}.
\end{align*}
Since $p$ is odd, $2$ is invertible modulo $p$. Hence either $i \equiv j \pmod{p}$ or $i \equiv -j \pmod{p}$. In the first case, $1 \leq i,j \leq m < p$ gives $i=j$. In the second case, $p \mid i+j$, but
\begin{align*}
2 \leq i+j \leq 2m=p-1,
\end{align*}
which is impossible. Thus $i=j$, so the $s_k$ are pairwise distinct. Since there are $m$ of them and all lie in $\{1,\dots,m\}$, they are precisely the elements of $\{1,\dots,m\}$ in some order.
Multiplying the congruences $s_k \equiv 2k \pmod{p}$ for $r_k<p/2$ and $s_k \equiv -2k \pmod{p}$ for $r_k>p/2$, we get
\begin{align*}
\prod_{k=1}^{m}s_k \equiv (-1)^N 2^m \prod_{k=1}^{m}k \pmod{p}.
\end{align*}
Since $\{s_1,\dots,s_m\}=\{1,\dots,m\}$, the left-hand product is $\prod_{k=1}^{m}k$. None of $1,\dots,m$ is divisible by $p$, so this product is invertible modulo $p$. Cancelling it gives
\begin{align*}
2^m \equiv (-1)^N \pmod{p}.
\end{align*}
By the definition of the Legendre symbol, $\left(\frac{2}{p}\right)=1$ exactly when $2$ is a square modulo $p$, and $\left(\frac{2}{p}\right)=-1$ otherwise. The standard Euler criterion for the Legendre symbol therefore gives
\begin{align*}
\left(\frac{2}{p}\right)\equiv 2^m \equiv (-1)^N \pmod{p}.
\end{align*}
Both $\left(\frac{2}{p}\right)$ and $(-1)^N$ belong to $\{-1,1\}$, and because $p$ is odd these two integers are congruent modulo $p$ only if they are equal. Hence
\begin{align*}
\left(\frac{2}{p}\right)=(-1)^N.
\end{align*}[/step]