Milan: Finishing third will save Ancelotti
"Carlo Ancelotti will stay if we come third," Galliani was quoted as saying by La Gazzetta dello Sport's website.
Milan, whose form has been poor, are clinging to third place in Serie A, which would send them directly into next season's Champions League.
A 2-1 defeat at Sampdoria on Sunday left them trailing leaders Inter Milan by 12 points and just two ahead of fourth-placed Fiorentina.
Ancelotti had already called an end to Milan's title hopes, saying a top three finish was their main target after they were knocked out of the UEFA Cup by Werder Bremen on Thursday.
The seven-times European champions were in the UEFA Cup after failing to qualify for the Champions League with a fifth-placed finish in Serie A last year.
Ancelotti, Serie A's longest serving coach having been appointed in 2001, led Milan to European Cup triumphs in 2003 and 2007 but has captured only one league title, in 2004.