Context. There is growing evidence that red giant evolution is often affected by an interplay with a nearby companion, in some cases taking the form of a common-envelope evolution. Aims. We have performed a study of the characteristics of the circumstellar environment of the binary object HD 101584, that provides information on a likely evolutionary scenario. Methods. We have obtained and analyzed ALMA observations, complemented with observations using APEX, of a large number of molecular lines. An analysis of the spectral energy distribution has also been performed. Results. Emissions from 12 molecular species (not counting isotopologues) have been observed, and most of them mapped with angular resolutions in the range 0 . 1 to 0 . 6. Four circumstellar components are identified: i) a central compact source of size ≈ 0 . 15, ii) an expanding equatorial density enhancement (a flattened density distribution in the plane of the orbit) of size ≈ 3 , iii) a bipolar high-velocity outflow (≈ 150 km s −1 ), and iv) an hourglass structure. The outflow is directed almost along the line of sight. There is evidence of a second bipolar outflow. The mass of the circumstellar gas is ≈ 0.5 [D/1 kpc] 2 M , about half of it lies in the equatorial density enhancement. The dust mass is ≈ 0.01 [D/1 kpc] 2 M , and a substantial fraction of this is in the form of large-sized, up to 1 mm, grains. The estimated kinetic age of the outflow is ≈ 770 [D/1 kpc] yr. The kinetic energy and the scalar momentum of the accelerated gas are estimated to be 7×10 45 [D/1 kpc] 2 erg and 10 39 [D/1 kpc] 2 g cm s −1 , respectively. Conclusions. We provide good evidence that the binary system HD 101584 is in a post-common-envelope-evolution phase, that ended before a stellar merger. Isotope ratios combined with stellar mass estimates suggest that the primary star's evolution was terminated already on the first red giant branch (RGB). Most of the energy required to drive the outflowing gas was probably released when material fell towards the companion.