Torre is viewed as a potential future star but will initially feature for the club's reserve team Barcelona B beginning this summer, before challenging for a first-team place in the medium term.
Barcelona stated the transfer fee was €5m with the amount potentially reaching €20m based on variables.
The 18-year-old attacking midfielder is now signed with the Blaugrana through June 2026, with a release clause of €100 million.
A number of top teams including Madrid had been tracking Torre, who has been starring for Racing this season, but Barca moved to wrap up negotiations on Friday.
The Spain Under-19 international has scored six goals in 21 appearances -- 18 of them starts -- for Racing to help them top their group in the Primera RFEF, the third tier of Spanish football.