We present an algorithm for the reconstruction of the Higgs mass in events with Higgs bosons decaying into a pair of tau leptons. The algorithm is based on matrix element (ME) techniques and achieves a relative resolution on the Higgs boson mass of typically 15-20%. A previous version of the algorithm has been used in analyses of Higgs boson production performed by the CMS collaboration during LHC Run 1. The algorithm is described in detail and its performance on simulated events is assessed. The development of techniques to handle tau decays in the ME formalism represents an important result of this paper.