ELKHART, Ind. (Reuters) - President Barack Obama said on Wednesday the decision to direct public schools to allow transgender students to use the bathrooms of their choice was based on the law and the best interests of the children.

Slideshow ( 2 images )

Speaking at a town hall event broadcast by the PBS television network, Obama, a Democrat, said the federal government waded into the controversial issue after school districts asked the Education Department for guidance.

Republicans have blasted the directive as executive branch overreach, and more than a dozen states have sued the Obama administration to block it.

“What happened and what continues to happen is you have transgender kids in schools. And they get bullied. And they get ostracized. And it’s tough for them,” Obama said.

“My best interpretation of what our laws and our obligations are is that we should try to accommodate these kids so that they are not in a vulnerable situation,” he said.

On May 13, the federal government told public schools they must allow transgender students to use bathrooms that correspond with their gender identity.

The non-binding guidance contained the implicit threat of cuts in federal funding if it was not followed. It relied on an interpretation of Title IX, which protects people from discrimination based on sex in education initiatives that receive federal financial assistance.

The directive came as the Justice Department and North Carolina battled in federal court over a North Carolina state law approved in March that prohibits people from using public restrooms not corresponding to the sex on their birth certificates. Other states are weighing similar measures.

“We should deal with this issue the same way we would want it dealt with if it was our child and that is to try to create an environment of some dignity and kindness for these kids,” Obama said.

Obama said there “are a lot of things more pressing” than the transgender bathroom controversy, including Islamic State, the economy and jobs.

“Somehow people think I made it an issue. I didn’t make it an issue,” he said.