Legg has had the growth removed however the operation confirmed that the cancer may have spread.
"Andy has been told there's a good chance the cancer may have spread, so he has been advised to give up playing," said Barry Fry.
"It's a terrible end to a glorious career, and he has the sympathy of everyone at the club."
Legg made 576 league appearances for seven different clubs, scoring 61 goals in that time in a career spanning 17 years.
Our thoughts go out to Andy and his family following this terrible news, and wish him all the best for the future.