The simulation of viscoelastic fluids is a challenging task from the theoretical and numerical points of view. This class of fluids has been extensively studied with the help of classical numerical methods. In this paper we propose a new approach based on the lattice Boltzmann method in order to simulate linear and non-linear viscoelastic fluids and in particular those described by the Oldroyd-B and FENE-P constitutive equations. We study the accuracy and stability of our model on three different benchmarks: the 3D Taylor-Green vortex decay, the simplified 2D four-rolls mill, and the 2D Poiseuille flow. To our knowledge, the methodology described in this work is a first attempt for the simulation of non-trivial flows of viscoelastic fluids using the lattice Boltzmann method to discretize the constitutive and conservation equations. (C) 2010 Elsevier B.V. All rights reserved.