The Gabon international, 23, made 42 appearances for Juve in two seasons, moving on loan from Marseille in 2015 before a £7.5m move last summer.
The Saints will pay an initial £15.4m with the rest depending on his success at the club.
He becomes Mauricio Pellegrino's second signing of the summer.
Saints vice-chairman Les Reed said Lemina's signing was a "significant statement of intent from the club".
Their previous record signing was Moroccan attacking midfielder Sofiane Boufal, who joined from French side Lille for £16m in August 2016.
Stoke, Watford and Leicester had all been linked with Lemina, who was left out of Juve's squad for their friendly against Tottenham at Wembley on Saturday.
Lemina, who began his career with Lorient, joined Juventus on a season-long loan in 2015 and his move was made permanent as he signed a four-year deal in April 2016.
In his time with the Bianconeri, he won both the Serie A title and the Coppa Italia twice, and featured in last season's Champions League final against Real Madrid.
Reed described Lemina as an "outstanding" talent, adding: "In a volatile market with some extraordinary and inexplicable transfers taking place, we are determined to go about our work in a diligent and correct way.
"This is a player who has won trophies and played in the Champions League final less than three months ago and he has signed for Saints amid a host of suitors."
Saints signed Poland Under-21 defender Jan Bednarek for £5m last month,
Find all the latest football transfers on our dedicated page.
Southampton have signed Juventus midfielder Mario Lemina in a club record deal worth up to £18.1m (20m euros) on a five-year deal.