PITTSBURGH — Women are making major gains in enrollment in engineering and computer science at some of the nation’s most prominent colleges and universities, a breakthrough that shows that gender parity is possible in technology fields long dominated by men.

More than half of engineering bachelor’s degrees at the Massachusetts Institute of Technology went to women in 2015, federal data show. The same was true at Dartmouth College this year. The majority of computer science majors at California’s Harvey Mudd College are women. Here at Carnegie Mellon University, women account for nearly half of first-year computer science students – 48 percent, a school record.

These and other examples underscore an evolution in fields vital to the nation’s economy. While men still far outnumber women nationally – four to one in engineering, five to one in computer science – female students are gaining ground slowly at many schools and rapidly at others. The movement seized attention last year when women fed up with gender stereotypes posted photographs of themselves on social media with a hashtag that went viral – ilooklikeanengineer.

The federal government and industry leaders acknowledge more should be done to bring women into science, technology, engineering and math, known as the STEM fields, and they have pushed programs such as Girls Who Code to boost interest among girls at a young age. Educators caution that many female students continue to face obstacles, including biases from classmates, teachers and others who might cause them to doubt their potential.

“There is systematic exclusion,” said Maria Klawe, Harvey Mudd’s president. “It used to be very deliberate, very conscious. I think it’s now much less conscious.”

Klawe, a computer scientist who is the college’s first female president, said that for generations talented women in STEM experienced “really annoying” snubs from men. But Klawe said she is seeing “significant progress” for female students at many schools even as the gender gap remains wide across the country.

In 2015, about 20 percent of bachelor’s degrees in engineering and 16 percent of those in computer science went to women, according to federal data. Those shares were each up 2 percentage points compared to five years earlier. At that rate, it could take decades to reach parity.

But some schools are making gains faster than others. Women earned at least a third of the engineering degrees at 31 schools in 2015, when considering schools that award 20 or more degrees a year in the field. Women reached that threshold in computer science at 16 colleges and universities.

Selective private schools, especially the most prestigious, hold an edge over public universities in the quest for gender balance. Those with lower enrollment and huge pools of qualified applicants often have wider latitude than state schools to use admissions to remake their gender profile.

Public schools have been moving slower toward gender equality in engineering and science. At the University of Maryland, for example, about 21 percent of engineering graduates and 15 percent of computer science graduates in 2015 were women. Those figures were close to the national averages.

At Carnegie Mellon, the head of the electrical and computer engineering department recounted one of her own experiences with male ignorance. Jelena Kovacevic said that after she earned her doctorate in electrical engineering from Columbia University in 1991, she was invited to speak at a conference. She arrived at the location and started preparing.

“I could see everybody was ignoring me,” Kovacevic said. “Then a guy asked me, when’s the speaker coming? I said, ‘It will be any minute.’ ” Jaws dropped when the audience figured out she was the speaker.

Thirty-six percent of Carnegie Mellon’s engineering undergraduates are women. The share is higher for first-year students: 43 percent. Female students are the majority in chemical engineering and civil and environmental engineering. But in Kovacevic’s department, just 25 percent are women.

“The culture is paramount,” she said.