The boy was outside Craigbank Primary School in Glengonnar Street, Larkhall, at about 20:45 on Sunday when he was approached by an older child.
The child threatened him with a weapon before taking his clothes.
Police said it was a "terrifying ordeal" for the eight-year-old boy and have appealed to witnesses to contact them.
Det Con David Timmons added: "Inquiries are ongoing to establish the full circumstances surrounding the incident.
"I would appeal to anyone who was in the surrounding area on Sunday evening, who may have witnessed what happened or may have captured the incident on their dashcam, to please get in touch."
An eight-year-old boy was robbed of his clothing in the grounds of a school in South Lanarkshire, police have said.