The idea that gender is a social construct and not an innate characteristic is widely accepted.
The National Institutes of Health (NIH) states that "gender is a social or cultural concept. It refers to the roles, behaviors, and identities that society assigns to girls and boys, women and men, and gender-diverse people. Gender is determined by how we see ourselves and each other, and how we act and interact with others."
Sex, on the other hand, is typically assigned at birth from characteristics such as chromosomes and genitalia.
As The New York Times has reported, "defining gender as a condition determined strictly by a person’s genitals is based on a notion that doctors and scientists abandoned long ago as oversimplified and often medically meaningless." Gender is thought to be at least influenced by your genetics, though. The same article explains that "In studies of twins, if one is transgender, the other is far more likely to also be transgender if they are identical, rather than fraternal twins."
If it is the case that gender is largely a social construct, then it does not follow that sex is wholly biology in nature.
Writing for the Lancet, anthropologist Katrina Alicia Karkazis explains that "debates about sex are often framed falsely as scientific versus cultural argument," adding that "it is long overdue that we understand sex not as an essential property of individuals but as a set of biological traits and social factors."
Kim Elsesser, writing for Forbes, explains that "Biological sex, it turns out, is a lot like gender identity—not always male or female, but occasionally somewhere in between."