We study the effect of viscoelastic dynamics on the frictional properties of a (mean-field) spring-block system pulled on a rough surface by an external drive. When the drive moves at constant velocity V, two dynamical regimes are observed: at fast driving, above a critical threshold V(c), the system slides at the drive velocity and displays a friction force with velocity weakening. Below V(c) the steady sliding becomes unstable and a stick-slip regime sets in. In the slide-hold-slide driving protocol, a peak of the friction force appears after the hold time and its amplitude increases with the hold duration. These observations are consistent with the frictional force encoded phenomenologically in the rate-and-state equations. Our model gives a microscopical basis for such macroscopic description.