Tam Baillie, the Scottish parliament's Commissioner for Children and Young People, has backed 13-year-old Luca Scarabello, who is fighting for a ban on "gender-specific uniforms".
Luca believes that if girls can wear trousers boys should be able to wear skirts.
Mr Baillie said that Luca, a pupil at St Mungo's High School in Falkirk, Stirlingshire, who lodged a petition with the Scottish Government in November, had "raised important rights issues".
He told the public petitions committee (PPC), which is considering Luca's proposals, that forcing uniforms on children could cause "serious distress" for those with gender variants.
But his stance has been condemned by family campaigners.
Norman Wells of the Family Education Trust, said: "Schools should be free to make their own decisions about uniform policies in consultation with parents, without the constraints of political correctness.
"Gender is determined by objective biological facts and not by a person's feelings, no matter how strong they may be. Rather than encouraging children to become what they are not, we need to help them recognise and accept what they are.
"To that end, maintaining a distinction between what boys and girls are required to wear can be positive and helpful for pupils struggling with gender identity issues.
"This is yet another case of the language of children's rights being used in an attempt to add weight to what is nothing more than a personal minority view.
"To enforce it on everyone by force of law is undemocratic."
But Mr Baillie argued: "We should be rejecting discriminatory practice and allowing our children and young people to express themselves.
"I would agree that gender specific uniforms or dress codes can cause serious distress in gender-variant pupils. School uniforms and dress codes should not be discriminate, directly or indirectly against any of these protected groups.
"Schools should be reviewing their uniform code policies to ensure they do not have the effect of unlawfully discriminating against pupils with a protected characteristic."
The young peoples' commissioner believes that forcing children to stick to strict uniform policies could contravene the UN convention on the Rights of the Child and the Equality Act 2010.
The latter law places a duty on public bodies to prevent discrimination on the grounds of gender-reassignment or sexual orientation.
However he accepted that having a uniform acts as a "leveller" between children of differing financial backgrounds and helped reduce stigma and bullying.
He added: "This is clearly an issue which divides people and there are strong views on both sides.
I believe we should be celebrating difference, rejecting discriminatory practice and allowing our children and young people to express themselves freely in a way that is both inclusive and respectful and helps them to develop a strong sense of who they are.
"I would suggest that a balance be struck between school dress codes on the one hand and the need for relaxation of requirements, where this is appropriate, on the other."
Mr Baillie made the comments as he lent his backing to teenager Luca Scarabello who is campaigning for boys to be allowed to wear the traditionally female clothing in class.
Parents Beck Laxton and Kieran Cooper said they did not want to 'stereotype' him.
We would love to know your thoughts on this one!
More on Parentdish: Meet Chris, the schoolboy who wore a skirt to school in uniform protest
Suggested For You
SUBSCRIBE AND FOLLOW
Get top stories and blog posts emailed to me each day. Newsletters may offer personalized content or advertisements.Learn more