The harmonic problem in electric power systems, far from improving, has been increasing in recent years. To mitigate this problem, active filters have been proposed; however, they do not present a complete solution for any type of load and system. This paper develops a control strategy for a compensator based on a hybrid filter topology. This topology is formed by an active power filter of series connection and a passive filter of parallel connection. The proposed strategy is based on minimizing the root-mean-square value of the voltage at the point of common coupling so that the source transfers the power demanded by the load. Thus, the determination of the reference signal is posed as a constrained optimization problem. The strategy was proposed for four- and three-wire systems, and it allowed the compensation of current harmonics and reactive power of harmonic current source and harmonic voltage source loads. An experimental prototype was developed, which has allowed verification of their performance.