In late 2016 and early 2017 the flat spectrum radio quasar CTA 102 exhibited a very strong and long-lasting outburst. The event can be described by a roughly 2 months long increase of the baseline flux in the monitored energy bands (optical to $gamma$ rays) by a factor 8, and a subsequent decrease over another 2 months back to pre-flare levels. The long-term trend was superseded by short but very strong flares, resulting in a peak flux that was a factor 50 above pre-flare levels in the $gamma$-ray domain and almost a factor 100 above pre-flare levels in the optical domain. In this paper we explain the long-term evolution of the outburst by the ablation of a gas cloud penetrating the relativistic jet. The slice-by-slice ablation results in a gradual increase of the particle injection until the center of the cloud is reached, after which the injected number of particles decreases again. With reasonable cloud parameters we obtain excellent fits of the long-term trend.