The workers, wrapped in blankets and wearing sunglasses to protect their eyes, emerged from the tunnel with raised arms and waving a Peruvian flag to celebrate their rescue, the state-run news agency Andina reported.
Humala greeted the miners as they emerged.
The plight of the miners, which drew worldwide interest, began Thursday when they were trapped by a cave-in at the wildcat mine near Yauca del Rosario. The rescue operation, hampered by a second cave-in during the weekend, moved cautiously so crews wouldn't dislodge rocks and possibly trigger a landslide, the president said.
Food, water and oxygen reached the miners through a special tube that also allowed them to communicate with people above ground.
It was unclear what caused the initial collapse.
During the rescue operation, government officials appealed to area mining companies for their expertise.
Humala said Wednesday his government has pushed for wildcat mines and miners to become more formal operations that can be regulated and risks reduced, CNN reported.
"This should lead us to reflect that we have to avoid these kind of risks because the results will not always be like today," Humala said.
Swim Week Miami Beach 2014 [PHOTOS]