This is in a landmark ruling that the child's lawyer said was a first step towards recognising intersex people.
Hospital staff put a question mark next to the box designating gender on a form to record the 2009 birth of the baby whose sex organs were not clearly female or male.
This meant the child never received a birth certificate, necessary to enjoy basic legal rights, such as attending school, getting a national identity document and voting.
"Now they are going to be able to get a birth certificate," the child's lawyer, John Chigiti, told the Thomson Reuters Foundation on Friday. "That's a win."
Intersex people often face stigma in Kenya as the condition is not understood. Local media referred to it as a "curse" for one nine-year-old child who was raised as a boy and dropped out of school because other students followed him to the toilet to see how he urinated.
The court also ordered the Attorney General to name a body that would take responsibility for conducting a census of intersex Kenyans and to develop guidelines and policies for their recognition and support.
"It's very comforting because if we are developing guidelines, it means that we have recognised them," Chigiti said.
Chigiti had less success when he represented Richard Muasya in 2010, an intersex person who was being sexually harassed in a male prison.
The court ruled that it was "an isolated case" and said Muasya did not represent a particular group of people.
Western countries often cluster intersex people together with other sexual and gender minorities, using the acronym Lesbian Gay Bisexual Transgender and Intersex (LGBTI). But this association has a negative impact in Kenya, activists say.
Homosexuality is outlawed and frowned upon by the majority of Kenyans, as it is across most of Africa where conservative values hold sway.
"Some will call them eunuchs, some will call them bisexual, some will call them transsexual," said Chigiti. "The general view of the public is a cocktail ... of confusion and fear."
In Kenya, parents often rush to have surgery performed on their children at a young age to avoid ridicule and stigma. Many intersex adults say their lives have been scarred by such operations.
"It's only the intersex person who knows what is best for them," said Chigiti.
Chigiti hopes Friday's court ruling will lead Kenya to adopt the practices of countries like South Africa, where intersex children cannot undergo surgery without a court order.
"The judge has to listen to the parents, listen to doctors, listen to experts, and if the child is able to (talk), listen to the child, and then come up with a decision based on the best interests of the child," he said.