BRAINTREE, Mass. — Conventional wisdom and popular perception hold that American students are falling further and further behind in science and math achievement. The statistics from this state tell a different story.

If Massachusetts were a country, its eighth graders would rank second in the world in science, behind only Singapore, according to Timss — the Trends in International Mathematics and Science Study, which surveys knowledge and skills of fourth and eighth graders around the world. (The most recent version, in 2011, tested more than 600,000 students in 63 nations.)

Massachusetts eighth graders also did well in mathematics, coming in sixth, behind Korea, Singapore, Taiwan, Hong Kong and Japan. The United States as a whole came in 10th in science and 9th in math, with scores that were above the international average.

Of course, Timss is only one test, and achievement tests are incomplete indicators of educational prowess. But behind Massachusetts’ raw numbers are two decades of sustained efforts to lift science and mathematics education. Educators and officials chose a course and held to it, even when the early results were deeply disappointing.