"We discovered this two hours ago. I have to stop," the former Giro d'Italia winner, 37, told a shocked news conference on Monday.
Basso was set to be one of Alberto Contador's key lieutenants in the mountains over the next two weeks.
He caught his groin in a crash on stage five and the cancer was discovered in a check-up on the race's first rest day.
Tinkoff-Saxo team-mate Contador was in tears as he sat next to Basso during his announcement.