A 6-year-old boy died Thursday after being hit by a rolling schoolyard fence that came off its track at the private Mark Day School in San Rafael, police said.

The fence is used to allow vehicles in and out of the schoolyard, near a large blacktop play area, said San Rafael police Lt. Dan Fink.

The incident appears to have been an accident. The exact circumstances are not yet known and under investigation, Fink said.

“What we’re looking at is the how and why this happened,” Fink said, “so that we can prevent anything like this from happening again.”

The incident was reported at 12:21 p.m. on the campus at 39 Trellis Drive, Fink said.

Members of the staff who witnessed the incident immediately called 911 and provided care to the student, school officials said.

San Rafael police and firefighters responded. The boy was transported to Kaiser Permanente Medical Center in San Rafael, where he died of his injuries.

Classes were in session Friday, but administrators of the K-8 school canceled the morning assembly and have made counselors available for students, Joe Harvey, head of school, said in a statement.

The scene of the accident has been closed off while authorities investigate, Harvey said.

“The safety of our students is so important to all of us, and we want to understand how this could have happened,” Harvey said.

“The death of someone so young is devastating for all of us, and even more so under these circumstances and at this time of year, when we are surrounded by celebrations while we mourn,” he said. “All of us at Mark Day School express our deepest sympathies to his family, classmates and friends.”