The gender gap in STEM starts earlier—much earlier—than you think.

According to new research, the disparity between boys’ and girls’ mathematical abilities actually begins in kindergarten. The study, which was published in AERA Open, a peer-reviewed journal of the American Educational Research Association, focused on groups of children starting kindergarten and tracked them several years into their education. The researchers found that while pupils of both genders entered school with similar math abilities, girls started to fall within the first year of their schooling. This contrary to the commonly-held notion that the gap in STEM skills starts to appear in middle school.

Joseph Robinson Cimpian, associate professor of economics and education policy at New York University, and his colleagues compared two kindergarten cohorts 12 years apart: the classes of 1998-1999 (who were tracked through third grade) and 2010-2011 (who were tracked through second). More than 5,000 students were included in the analysis of the first cohort and more than 7,500 in the second.

The researchers looked specifically at the gender gap in math, looking to identify when disparities first appear, where in the distribution they develop (i.e. among low achievers or high achievers), and whether those trends changed between the 1998 group and the 2010 group. In addition to pure levels of achievement, they also examined two potential contributors to the gender gap: students’ learning behavior and teacher expectations.

The patterns were similar in both groups: Boys and girls entered kindergarten with similar abilities, but by first grade the girls started to fall behind. By third grade there were significant disparities. The similarities between the two groups of students were surprising to Cimpian, who says he expected the 2010 cohort to have a smaller gap. A similar study by Accenture and Girls Who Code that focused on older students also showed that the gender gap in STEM isn’t shrinking—in fact, it’s actually getting wider.

Teachers’ expectations may be one potential explanation for the fact that the gap kicks in at such a young age. The study found that when students of both genders behaved and performed identically on tests, teachers rated girls’ math skills as worse than boys’.

Expectations—particularly teachers’ expectations—have been shown to be useful predictors in performance, a psychological phenomenon known as the Pygmalion effect. In the 1960s, researchers Robert Rosenthal and Lenore Jacobsen showed that when teachers expected students to outperform others in their class, they did so. The effect was the same when teachers expected students to underperform.

“It’s pretty scary because this is where the foundation is being laid for interest in math,” Cimpian says. “Oftentimes we look at things a little too late. We look at higher education, we look at what’s going on in high school, but the foundation has already been laid [at a younger age].”

Subscribe to the Broadsheet, Fortune’s daily newsletter on the world’s most powerful women.

While Cimpian’s research didn’t dive into the reasons for teachers’ lowered expectations for girls, he points to a fascinating 2009 study by University of Chicago professor Sian Beilock as a potential explanation.

In her study, Beilock looked at how early childhood teachers’ “math anxiety”—basically what it sounds like—affects students. The study concludes: “In early elementary school, where the teachers are almost all female, teachers’ math anxiety carries consequences for girls’ math achievement by influencing girls’ beliefs about who is good at math.”

With this in mind, Cimpian says, “We need to look where the biases are creeping in and work to undo [them].”