The main goal of this study is to find the solution of initial boundary value problem for the one-dimensional time and space-fractional diffusion equation which is a very intriguing topic for many researchers. With the aim of newly defined inner product, which is the main contribution of this study, the analytic solution of the boundary value problem is obtained. The time and space-fractional derivatives are defined in the Caputo sense which is more suitable than Riemann-Liouville sense. We apply the separation of variables method to reduce the problem to two separate fractional ODEs. The generalized solution is constructed/formed in the form of a Fourier series with respect to the eigenfunctions of a certain eigenvalue problem. In order to obtain the coefficients of the Fourier series for the solution, we define a new inner product which is the key point of study.