In this paper, based on the idea of the extended Ritz method, we introduce an efficient approximate technique for solving a general class of fractional variational problems. In the discussed problem, the fractional derivatives are considered in the Caputo sense. First, we introduce a family of fractional polynomial functions with a free parameter in the exponent. With the aid of the presented fractional polynomials, we construct a family of functions with free parameters, which provides the extended Ritz method with a great flexibility in searching for the approximate solution of the problem. The approximate solutions satisfy all the initial and the boundary conditions of the problem. The convergence of the method is analytically studied and some test examples are included to demonstrate the superiority of the new technique over the ordinary Ritz method.