An experiment investigating the production of relativistic electrons from the interaction of ultrashort multi-terawatt laser pulses with an underdense plasma is presented. Electrons were accelerated to tens of MeV and the maximum electron energy increased as the plasma density decreased. Simulations have been performed in order to model the experiment. They show a good agreement with the trends observed in the experiment and the spectra of accelerated electrons could be reproduced successfully. The simulations have been used to study the relative contribution of the different acceleration mechanisms: plasma wave acceleration, direct laser acceleration and stochastic heating. The results show that in low density case (1 percent of the critical density) acceleration by laser is dominant mechanism. The simulations at high density also suggest that direct laser acceleration is more efficient that stochastic heating.