National tests measuring science knowledge among eighth-graders show slight improvement compared with those of two years earlier,but one-third of all students still lack a basic understanding of the physical, life and earth sciences, according to a federal study made public Thursday.

The tests showed that black and Hispanic students had made slightly more progress than white students, making a tiny dent in the persistent achievement gaps between the racial groups.

The gender gap also has proved stubborn, with boys continuing to outperform girls in the science test, a trend consistent with results from 2009, the previous year the test was given.

Despite barely significant increases in performance among most every group, scores remained flat for top-performing students. Just 2 percent of all students tested were considered advanced.

Private school students outpaced public school students nationwide. And students who reported that they regularly performed hands-on science projects in class scored higher than students who less frequently did that kind of class work.

The study is based on the 2011 National Assessment of Educational Progress. The tests are given in different subjects and periodically to fourth-, eighth- and 12th-graders across the country.

The tests, often called The Nation’s Report Card, are the only continuing and nationally representative assessment of what students know.

Education Secretary Arne Duncan said the slight increase in test scores and narrowing of the achievement gap were promising but that the country has a long way to go. “This tells me that we need to work harder and faster to build capacity in schools and in districts across the country,” Duncan said in a statement. “We have to do things differently; that’s why education reform is so critical.”

Gerry Wheeler, interim executive director of the National Science Teachers Association, was blunt. “This is dreadful,” he said.

Wheeler said No Child Left Behind, the 2002 federal education law, is partly to blame, because it emphasized reading and mathematics at the expense of science. “As a country, we’ve backed off on science,” he said. “We even have members in elementary schools who say, ‘My principal told me to stop teaching science.’ ”

It is difficult to say how the 2011 results fit into a larger trend line of student performance. The National Assessment Governing Board, which sets policy for the test, changed the framework for the science exam two years ago, making comparisons to tests prior to that impossible.

In Virginia, students scored higher than the national average and posted higher scores in 2011 than they did in 2009. The performance gap between white students and blacks and Hispanics did not change between 2009 and 2011.

In Maryland, students performed the same as the national average for public school students. The average Maryland scores were four points higher in 2011 than in 2009 but the percentage of students performing at the proficient and basic levels did not change over the two years. The performance gap between white students and other racial groups, as well as between poor students and those from more affluent families, did not significantly change between 2009 and 2011.

One bright spot in Maryland is the fact that the gender gap seems to have largely disappeared. On average, boys and girls scored alike on the science test, and the same percentage of males and females were deemed basic or proficient. But a greater percentage of boys than girls were deemed advanced.

Students in the District turned in the worst performance in the region, performing significantly below the national average. The achievement gap between whites and blacks was nearly twice as wide as the national average, and the gap between white students and Hispanics was also wider than the national average. D.C. schools did not participate in the voluntary testing in 2009, so no comparisons to earlier results can be made.

The results come as corporations, the military and the federal government are growing increasingly concerned about U.S. students and their mastery of the STEM subjects — science, technology, engineering and math.

President Obama, who hosted a science fair at the White House in February and spoke about the need to improve science and technology education in his State of the Union address, wants to train 100,000 new math and science teachers over the next decade. He intends to contribute federal dollars to a $100 million program led by the Carnegie Corporation to create more science teachers.

Those efforts are not enough, Wheeler said. “The message is getting lost at the local level, and that’s where the change has to happen,” he said. “Otherwise, it’s pretty much a scatter gun thing — there’s no united effort to bring these children forward.”

Compared with 2009, the average science scores in 2011 were one point higher for white students, three points higher for black students and five points higher for Hispanic students. There were no significant changes in scores for Asians.