A series of analytical solutions are presented for viscous compacting flow past a rigid impermeable sphere. The sphere is surrounded by a two-phase medium consisting of a viscously deformable solid matrix skeleton through which a low-viscosity liquid melt can percolate. The flow of the two-phase medium is described by McKenzie’s compaction equations, which combine Darcy flow of the liquid melt with Stokes flow of the solid matrix. The analytical solutions are found using an extension of the Papkovich–Neuber technique for Stokes flow. Solutions are presented for the three components of linear flow past a sphere: translation, rotation and straining flow. Faxén laws for the force, torque and stresslet on a rigid sphere in an arbitrary compacting flow are derived. The analytical solutions provide instantaneous solutions to the compaction equations in a uniform medium, but can also be used to numerically calculate an approximate evolution of the porosity over time whilst the porosity variations remain small. These solutions will be useful for interpreting the results of deformation experiments on partially molten rocks.