Consider the contour integral
$$\oint_C dz \, z^{a-1} \, e^{i z}$$
where $C$ is a quarter circle of radius $R$ in the 1st quadrant (real and imaginary $> 0$), with a small quarter circle of radius $\epsilon$ about the origin cut out (to avoid the branch point at the origin).
This integral is equal to
$$\int_{\epsilon}^R dx \, x^{a-1} \, e^{i x} + i R^a \int_0^{\pi/2} d\theta \, e^{i a \theta} e^{i R \cos{\theta}} \, e^{-R \sin{\theta}}\\+ i \int_R^{\epsilon} dy \, e^{i \pi (a-1)/2} y^{a-1} e^{-y} + i \epsilon^a \int_{\pi/2}^0 d\phi \, e^{i a \phi} \, e^{i \epsilon e^{i \phi}}$$
We note that the second integral vanishes as $R\to\infty$ because $\sin{\theta} \gt 2 \theta/\pi$, so that the magnitude of that integral is bounded by
$$R^a \int_0^{\pi/2} d\theta \, e^{-R \sin{\theta}} \le R^a \int_0^{\pi/2} d\theta \, e^{-2 R \theta/\pi} \le \frac{2}{\pi R^{1-a}}$$
We also note that the fourth integral vanishes as $\epsilon^a$ as $\epsilon \to 0$. In the third integral, we write $i=e^{i \pi/2}$ to make a simplification.
The contour integral is zero by Cauchy's Theorem (no poles in the interior of $C$). Ths we have (+)
$$\int_{0}^{\infty} dx \, x^{a-1} \, e^{i x} - e^{i \pi a/2} \int_0^{\infty} dy \, y^{a-1} \, e^{-y}=0$$
We use the definition of the gamma function:
$$\Gamma(a) = \int_0^{\infty} dy \, y^{a-1} \, e^{-y}$$
and take real parts of (+) to obtain the sought-after result.