Why do these two definitions of momentum in QM coincide? In the path integral picture of QM, one acts with the momentum operator $\hat{p}$ by inserting the quantity $$\hat{p}~=~\widehat{\frac{\partial L}{\partial \dot{x}}}$$ into the path integral.
I would like to know if there's a path integral justification for why this agrees with the usual definition of momentum as $$\hat{p} = -i\hbar\frac{\partial}{\partial x}.$$
 A: Any state, say living at $t=0$, can be prepared by a path integral on the lower half Euclidean plane $\tau <0$ (where $\tau$ is imaginary time) with some appropriate insertions $\mathcal{O}$ away from $\tau =0$:
$$\tag{1} \psi(x) = \int_{x(t=0)=x}Dx e^{-S} \mathcal{O}. $$
To deduce the effect of applying $-i{\partial}_x$ to $\psi$, use (1) to expand $\psi(x+\delta x)$ as a path integral:
\begin{align}
\tag{2} \psi(x+\delta x) &= \int_{x(t=0)=x+\delta x}Dx e^{-S} \mathcal{O} \\
&= \tag{3}\psi(x) + \delta x \int_{x(t=0)=x}Dx \frac{\delta}{\delta x(0)}e^{-S} \mathcal{O} \\
&= \tag{4}\psi(x) - \delta x \int_{x(t=0)=x}Dx \left(\frac{\delta S}{\delta x(0)}\right)e^{-S} \mathcal{O}.
\end{align}
Comparing both sides, we see that applying $-i\partial_x$ to $\psi$ is equivalent to inserting $i\frac{\delta S}{\delta x(0)}$ in the Euclidean path integral. But $\frac{\delta S}{\delta x(0)}$ is nothing other than the momentum. To see this, recall how the action changes when we vary $x(\tau)$ for $\tau \leq 0$:
$$\tag{5} \delta S = \int_{\tau<0} d\tau  \left(\frac{\partial L}{\partial x}-\frac{d}{dt}\frac{\partial L}{\partial \dot{x}}\right) \delta x(\tau) + \left[\frac{\partial L}{\partial \dot{x}}\delta x(\tau)\right]^{0}_{-\infty}$$
and so $$\tag{6}\frac{\delta S}{\delta x(0)} = \frac{\partial L}{\partial \dot{x}(0)} = p(0).$$
Therefore we've found that acting with $-i\partial_x$ is the same as inserting $ip$ into the Euclidean path integral. In Lorenztian signature this is equivalent to just inserting $p$ (with no factor of $i$), as we wished to show.
A: OP already gave an answer using the boundary of the path integral. In this answer, we instead consider the bulk.
The starting point is the equivalence between the operator formalism and the Hamiltonian/phase space path integral formalism, cf. e.g. this related Phys.SE post.

*

*OP's first momentum definition, aka. the Schrödinger representation $$\hat{p}=\frac{\hbar}{i}\frac{\partial}{\partial q}\tag{A}$$ is essentially tied to the CCRs. The CCRs are a first principle in the operator formalism, and can be deduced from the path integral formalism using the Schwinger-Dyson (SD) equations along lines laid out in my Phys.SE answer here.


*To get to the Lagrangian path integral we have to perform an inverse Legendre transformation of our starting point: the Hamiltonian path integral. Alternatively, this can be achieved by introducing a velocity field in an extended ($E$) path integral
$$\begin{align} Z_E~=~&\int\! {\cal D}q {\cal D}p{\cal D}v~e^{\frac{i}{\hbar}S_E[q,v,p])}\cr
~=~&\int\! {\cal D}q ~e^{\frac{i}{\hbar}\int\!dt~L(q,\dot{q},t)},\end{align}\tag{B}$$
of an extended ($E$) action
$$  S_E[q,v,p]~=~\int\!dt\{ p(\dot{q}-v)+L(q,v,t)\}, \tag{C}$$
cf. my related Phys.SE answer here. Then the SD equations yield OP's second momentum definition
$$\begin{align} 0~=~&i\hbar\langle \frac{\delta F[q,p]}{\delta v(t)}\rangle\cr
~\stackrel{\text{SD eq.}}{=}&\langle F[q,p]\frac{\delta S_E[q,v,p]}{\delta v(t)}\rangle\cr
~\stackrel{(C)}{=}~&\langle F[q,p]\left(p(t)-\frac{\partial L(q(t),v(t),t)}{\partial v(t)} \right)\rangle. \end{align} \tag{D}$$
