The athlete, who had been scheduled to run the women's 100 and 200 metres, left the Olympic Village on Sunday and returned home, the country's Olympic Committee said.
"In discussion with team management, Ms. Williams volunteered information to the effect that she has been using a substance which the SKNOC considers to fall outside the internationally accepted medical code," it said.
The SKNOC did not provide any details on the substance Williams admitted to using and said an investigation was under way.
Williams could now face up to a two-year ban as a first time offender but could also get a shorter sentence or even no punishment after voluntarily providing the information and depending on the nature of the anti-doping rule violation.
She is the third doping case at the Olympics after an Albanian weightlifter and an Uzbek gymnast tested positive for banned substances.
The 22-year-old Williams, fourth in the 200m in last year's Pan-American Games, was due to compete in her first Olympics.
- Related links