Nonperturbative renormalization of the chiral nucleon-nucleon interaction up to next-to-next-to-leading order