Editor’s note: This editorial has been updated to reflect the correction below.

Access to birth control and sex education in the schools is paying off.

Recently released figures from the Executive Office of Health and Human Services show Massachusetts has the lowest teen birth rate in the nation —a milestone attributed to increased access to affordable family planning and sex education in the schools.

The Massachusetts rate is 9.4 per 1,000 girls ages 15 to 19, compared with a national rate of 22.1 per 1,000. And it’s been declining for several years.

But while we have much to celebrate with the continuing decline in teen births, much remains to be done.

One troubling trend in the statistics just released is the disparity in rates between nearby communities. Lawrence, for example, has the fourth-highest rate in Massachusetts, at 32.4 per 1,000 teen girls, and Lynn is right behind it at 32.3 per 1,000. Haverhill and Methuen have teen birth rates that are lower than the national average but still higher than the state average, and still troubling.

But surrounding cities and towns have far lower rates. Peabody, which is right next to Lynn, has a rate of only 3.6 per 1,000. Newburyport, just down the river from Haverhill, had no teen births, while Haverhill’s rate was 20.1 per 1,000.

Several factors are at play here.

One is economics; communities with large low-income populations tend to have higher teen birth rates. Religious background, which might limit access to contraception, can also be a factor. And ethnicity plays a role: Hispanic teenagers have a birth rate that is seven times higher than that for non-Hispanic teens. In Peabody, for example, 60 percent of its teen births were to Hispanic girls.

Advocates also cite the quality of sex education programs. In Lawrence, where the teen birth rate is also falling, the sex ed curriculum includes birth control but emphasizes abstinence. That focus may help explain the city’s teen birth rate, according to Nicole Castillo, director of the Massachusetts Alliance on Teen Pregnancy.

“Abstinence-only sexual education doesn’t work,” she said. “It’s medically inaccurate.”

Massachusetts has shown it knows how to prevent teen pregnancies, but those strategies need to be more widespread to reach at-risk kids. Even low-income teens can usually find access to low-cost birth control, either at a school-based health center or a clinic such as Health Quarters or Planned Parenthood. Ensuring that those free or low-cost choices remain available continues to be important.

Locally, however, it would be hard to overstate the value of education, and it is here where the Legislature can make a difference. Massachusetts does not require schools to provide sex education and does not set any standards for schools that do provide it. The result, says Jennifer Childs-Roshak, president of Planned Parenthood League of Massachusetts, is that “school districts are all over the place on it.”

A first step was proposed two years ago in a bill that would have required schools that teach sex ed to do so in a way that is “medically accurate” and “age-appropriate.” Whether to teach sex ed in the first place remained a decision for local school leaders.

That bill didn’t pass. It has been refiled, and among local legislators who’ve signed onto it are Sen. Joan Lovely, D-Salem; Rep. Lori Ehrlich, D-Marblehead; Sen. Barbara L’Italien, D-Andover; and Rep. Juana Matias, D-Lawrence.

Ensuring that programs meet some minimum requirements is a start, and it’s one that should receive widespread support on Beacon Hill this year.

Teen births have a huge impact on the teenage mothers, their babies and on society, in general, which usually ends up paying financially and socially when kids have kids of their own. Fortunately, this is happening less frequently nowadays, but we can still do better.

CORRECTION: A story about teen births in Monday’s Gloucester Daily Times and an editorial published Tuesday incorrectly reported data for several cities as percentages. Birth rates are reported per 1,000 girls ages 15 to 19. For example, the state’s teen birth rate in 2015 was 9.4 per 1,000 girls ages 15 to 19, according to the state Department of Public Health. This editorial has been updated accordingly.