The paper establishes a characterization of the compactness for fractional operators of a general class, including the Riemann-Liouville, Hadamard and Erdelyi-Kober operators. The paper considers an integral fractional integration operator of Hardy type with nonnegative kernels and a variable limit of integration (a function as the upper limit of integration) and under certain conditions on the kernel, a criterion of the compactness in weighted Lebesgue spaces is obtained for this operator, when the parameters of the spaces satisfy the conditions Moreover, more general results are obtained for the weighted differential inequality of Hardy type on the set of locally absolutely continuous functions that vanish and infinity at the ends of the interval, covering the previously known results, and more precise estimates for the best constant are given. The localization method, Schauder’s theorem, the Kantorovich test, and the theorem on the uniform limit of compact operators were used in the proof of the main theorem. The obtained results of the study the compactness of fractional integration operators can be used in the estimation of solutions of differential equations that model various processes in mathematics. In particular, these results yield new results in the theory of Hardy-type inequalities.