"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.
Basso, who will travel to Italy to undergo surgery as soon as possible, twice finished on the podium during Lance Armstrong's long reign at the Tour and many, including Armstrong, expected him to follow the American on to the top step when he retired in 2005.
-BBC