  We present and analyze a space-time Petrov-Galerkin finite element method for
a time-fractional diffusion equation involving a Riemann-Liouville fractional
derivative of order $\alpha\in(0,1)$ in time and zero initial data. We derive a
proper weak formulation involving different solution and test spaces and show
the inf-sup condition for the bilinear form and thus its well-posedness.
Further, we develop a novel finite element formulation, show the well-posedness
of the discrete problem, and establish error bounds in both energy and $L^2$
norms for the finite element solution. In the proof of the discrete inf-sup
condition, a certain nonstandard $L^2$ stability property of the $L^2$
projection operator plays a key role. We provide extensive numerical examples
to verify the convergence of the method.
