The move comes after months of negotiations and will give Ganso, 22, the chance to boost his stalled career. The cultured midfielder was until recently considered one of the hottest prospects in the game.
"Ganso showed throughout the negotiating a great willingness towards Sao Paulo. He gave up big things and was firm in his desire. If it wasn't for his desire, we would had given up," Sao Paulo football director Adalberto Baptista told the club website.
Alongside his friend Neymar, Ganso helped Santos to five titles over the last two years, including the 2011 Copa Libertadores, South America's equivalent of the Champions League.
But he has been beset by injuries and loss of form and Santos fans turned against him after he asked for a salary increase.
He has played just five times in Santos' current league campaign and was left out of the recent Brazil squad.
At Sao Paulo he will be expected to replace Lucas, the teenage midfielder who signed for Paris Saint-Germain last month for 43 million euros. Lucas joins the French club when the Brazilian league season ends in December.
Ganso joins a club in fifth place in the Brazilian first division and will line up alongside former Arsenal midfielder Denilson, the club's long-serving goalkeeper Rogerio Ceni and Brazil centre forward Luis Fabiano.