"We discover this two hours ago, I have to stop," the 37-year-old Italian told a news conference on the first rest day of this year's Tour.
"I crashed in the fifth stage and I felt pain in my left testicle and I went for checks," said Basso, who was addressing the media ahead of his Tinkoff-Saxo team leader Alberto Contador.
Spain's Contador, who is attempting a rare Giro/Tour de France double, would not discuss the race, in which he sits fifth overall, one minute three seconds behind leader Chris Froome.
"I have grown closer to Ivan in the past weeks and this is terrible news," said Contador.
Basso looked on course for Tour glory when he won the white jersey for the best Under-25 rider in 2002, in an era dominated by the disgraced Lance Armstrong, a testicular cancer survivor.
"Thinking about Ivan Basso and wishing him the very best as he embarks on his cancer journey," Armstrong said on Twitter.
He never won the world's greatest race, however, finishing third and second overall in 2004 and 2005 respectively.
Basso won the Giro twice -- his only grand tour titles -- thanks to impressive climbing performances.
Image: Ivan Basso
Photograph: Stephane Mahe/Files/Reuters
His career, however, was stained with a two-year ban for his implication in the Operation Puerto blood-doping scandal.
Basso admitted to "attempted doping" in 2007 and was hit by a backdated suspension.
He won the Giro less than two years after his comeback from suspension but only managed seventh in the 2007 Tour. He was one of Contador's lieutenants on this year's Tour having helped the Spaniard win the Giro last month.
Tour de France: Vuillermoz shines, Froome leads
Tour de France: Froome, Contador back in control
Tour de France: Froome takes lead; Martin crashes out
Diary of a first-time dad: Inside the labour room
'Manchester United is the only club that I would have left Munich for'