Llorente, capped five times by Spain, began his career at Real Madrid and moved to Sociedad in 2017. He made 88 appearances in all competitions for the team, scoring eight goals.
"Leeds United are delighted to announce the signing of defender Diego Llorente," said a club statement. "The 27-year-old joins the club from La Liga outfit Real Sociedad for an undisclosed fee.
Llorente said the move was an "honour".
"For me the Premier League is the competition that is the most important in the world of football and it is a challenge to be here and I'm looking forward to getting started and helping my teammates," he said.
"Marcelo Bielsa was also a key factor. For me he is the greatest manager in the world and it is an honour. I've come to learn as much as possible from him."
Llorente is the fourth major signing for Leeds since manager Bielsa guided them back to the Premier League after a 16-year absence.
Germany defender Robin Koch joined from Freiburg and Portuguese international winger Helder Costa had his loan spell turned into a permanent move.
The 26-year-old Costa scored twice in Leeds' 4-3 win over Fulham last weekend to secure their first points of the season.