A method for optimizing potential-energy functions of proteins is proposed. The method assumes a hierarchical structure of the energy landscape, which means that the energy decreases as the number of native-like elements in a structure increases, being lowest for structures from the native family and highest for structures with no native-like element. A level of the hierarchy is defined as a family of structures with the same number of native-like elements (or degree of native likeness). Optimization of a potential-energy function is aimed at achieving such a hierarchical structure of the energy landscape by forcing appropriate free-energy gaps between hierarchy levels to place their energies in ascending order. This procedure is different from methods developed thus far, in which the energy gap and/or the Z score between the native structure and all non-native structures are maximized, regardless of the degree of native likeness of the non-native structures. The advantage of this approach lies in reducing the number of structures with decreasing energy, which should ensure the searchability of the potential. The method was tested on two proteins, PDB ID codes 1FSD and 1IGD, with an off-lattice united-residue force field. For 1FSD, the search of the conformational space with the use of the conformational space annealing method and the newly optimized potential-energy function found the native structure very quickly, as opposed to the potential-energy functions obtained by former optimization methods. After even incomplete optimization, the force field obtained by using 1IGD located the native-like structures of two peptides, 1FSD and betanova (a designed three-stranded β-sheet peptide), as the lowest-energy conformations, whereas for the 46-residue N-terminal fragment of staphylococcal protein A, the native-like conformation was the second-lowest-energy conformation and had an energy 2 kcal/mol above that of the lowest-energy structure.