The 35-year-old Valencia made the decision after playing just 15 matches in almost six months for Mexican side Queretaro.
"It is a tough decision. I feel mentally strong, I feel good, but there is something that is not right with my body, and that's my knee," he told a virtual news conference, Xinhua reports.
"It is time to say thanks to this beautiful sport. If I've let anybody down, I apologise. I've always tried to give my all for my country."
Valencia was capped 99 times for Ecuador's national team in a career that included a decade at Manchester United as well as spells with Villarreal, Wigan Athletic and LDU Quito, among other clubs.