Stop-and-go waves, also called phantom jams, are often observed in real traffic flows but can be produced neither by the classical Lighthill–Whitham–Richards (LWR) model nor by its known variants. To capture stop-and-go waves, we add hysteresis to the LWR model. For the model we propose, all possible viscous waves are found, and necessary and sufficient conditions for their existence are provided. In particular, deceleration and acceleration shocks appear; the latter were never rigorously defined before, in spite of the fact that they were observed in real traffic flows. Stop-and-go waves can be constructed by a pair of deceleration and acceleration shocks that completes a hysteresis cycle, illustrating how hysteresis loops lead to stop-and-go waves. In contrast, in the phase region where anticipation (i.e. negative hysteresis) loops exist, stop-and-go waves are not present, and speed variations decay. Riemann solutions are then found for all possible Riemann data. We explicitly show that, in the phase region where hysteresis loops exist, a sufficient deviation in speed of a few vehicles in an otherwise uniform car platoon can generate stop-and-go waves, confirming observations of real traffic experiments.