The Hamiltonian constraint remains the major unsolved problem in loop quantum gravity (LQG). Some time ago, a mathematically consistent candidate Hamiltonian constraint was proposed but there are still several unsettled questions which concern the algebra of commutators among smeared Hamiltonian constraints which must be faced in order to make progress. In this paper, we propose a solution to this set of problems based on the so-called master constraint which combines the smeared Hamiltonian constraints for all smearing functions into a single constraint. Due to a harmonic interplay of several mathematical facts, the problems with the commutator algebra disappear and chances are good that one can control the solution space and the (quantum) Dirac observables of LQG. Even a decision on whether the theory has the correct classical limit and a connection with the path integral (or spin foam) formulation could be in reach.