A D.C. elementary school mistakenly turned over the wrong ­second-grader to a child-welfare worker arranging a visit between a foster child and his father, city officials said Tuesday.

The director of the Child and Family Services Agency said the mix-up happened Jan. 31. The worker presented identification to Harriet Tubman Elementary School and asked for the foster child by his full name. Instead, the school brought out another student who shares the same unusual first name.

Officials did not realize anything was amiss until the child’s family came to pick him up from school, only to be told he was with a child-welfare official.

The child was reunited with his father nearly two hours after he was removed, a police report says.

Brenda Donald, the director of the child-welfare agency, said in an interview that the worker was not the foster child’s primary caseworker and had not met him before. The child also did not raise questions about leaving the school, Donald said.

“He’s a little kid, and usually the schools are trying to explain in a nice way that here’s a nice person from CFSA who is going to take you to McDonald’s to have lunch,” Donald said. “It was a mistake, and it’s explainable. And again, I can understand the family being upset.”

In a letter to parents of Tubman students, Principal Amanda Delabar said, “This incident led us to reinforce our sign-out procedures and remind all staff of our school security protocols.”

Asked about the incident, a D.C. schools official referred to Delabar’s letter and did not dispute the CFSA account.

The mix-up was first reported by Washington City Paper.

The boy’s relatives could not immediately be reached for comment. His grandfather told City Paper that school officials had to review security footage from the Columbia Heights school to figure out that the student was removed by a child-welfare worker. The school then contacted police, who in turn contacted the child-welfare agency.

His mother told City Paper that he did not want to return to school and was scared of being taken by a stranger again.

Donald said the child was always supervised. The city employee originally took the child to the McDonald’s, bought him a Happy Meal and then took him to the agency headquarters when the foster child’s parent did not show up. There, city officials realized the error.

Donald could not recall a similar incident during her time at the agency. “This is just a rare situation,” Donald said. “I’m sure we will probably want to double-check and schools want to double-check because no one wants this to happen.”

D.C. school administrators have previously grappled with concerns over the safety of students when turned over to adults.

In October, a registered sex offender allegedly tried to abduct two brothers from a D.C. charter school, sparking citywide concerns about safety and dismissal procedures on school grounds.

The incident occurred at Rocketship Rise Academy Public Charter in Southeast Washington. A man walked into the school gym and began playing basketball with a 9-year-old child. He then allegedly walked outside with the boy and his younger brother, stopping when a school employee intervened and questioned his relationship with the children, according to court documents.

Education officials then launched a comprehensive review of safety and dismissal policies at charter schools.

Peter Hermann contributed to this report.