New Bayern coach Pep Guardiola had said last Wednesday that "it was Thiago or nobody" on his wish list of new players at the Champions League winners and the midfielder, who had also been linked with a move to Manchester United, will fly to Munich for his medical in the coming days.
Bayern will pay €20 million for the 22-year-old with the extra five million coming from a future friendly match between the two clubs.
Thiago scored a first-half hat-trick for Spain in the final of last month's European Under-21 Championships to claim a 4-2 win over Italy.
"Thiago Alcantara was the main wish of our new coach Pep Guardiola," said Bayern chairman Karl-Heinz Rummenigge.
"We are pleased that we succeeded in making this great transfer happen.
"Thiago has only just been elected the best player of the Under-21 European Championship. He is a fantastic player with great perspective, which will strengthen Bayern."
Bayern claimed their sixth win from their sixth pre-season friendly on Sunday with a 4-0 win at German third division side Hansa Rostock.
But ahead of the Bundesliga resumption on August 9th, Thiago's arrival will only heighten competition in Bayern's midfield with Germany star Mario Goetze, another new signing from Borussia Dortmund, also vying with stars Arjen Robben, Franck Ribery, Toni Kroos and Thomas Mueller.