Measles continues to spread in Massachusetts, with two new cases confirmed this week, including one involving a 23-month-old boy from Boston who had received his first measles vaccination last year, according to the Boston Public Health Commission. The other was a teenage boy from outside the city who was treated at a Boston health care facility.

That brings the state total to 17 this year — and counting. In each of the previous four years, Massachusetts has had one to three cases. The surge has been occurring nationwide as well, with federal health officials announcing Tuesday that measles cases have been on their fastest pace since 1996. So far this year, 118 infections have been reported in 23 states, compared with 50 in a typical year.

Twelve of the Massachusetts cases have been reported this month, and most of the patients have no known connections. The seemingly random strikes by the virus have public health officials worried about containing the spread.

“In a number of cases, we don’t really know where people got it, and that’s of concern,’’ said Dr. Anita Barry, director of the infectious disease bureau at the Boston Public Health Com mission.

Back in February two cases were tied to the French Consulate, in the Back Bay, and last week measles was confirmed in two elementary school students who attend the Driscoll School in Brookline. The two students are related and had not been vaccinated. A few other cases were attributed to recent overseas travel to France and other countries with significant measles outbreaks.

France reported 10,000 cases — and six deaths — during the first four months of the year, most likely due to low vaccination rates. The US Centers for Disease Control and Prevention attributes the rise in measles cases in this country to the surge in cases globally, most notably in France, India, and the Philippines.

The cases this week, however, cannot be explained, except for the fact that the virus is very contagious and remains infectious and airborne for up to two hours after an infected person has been in the area, Barry said. Most likely, the individuals unknowingly came into contact with someone who was infected.

The 23-month-old boy developed full-blown symptoms of fever, rash, red watery eyes, and cough. Although he was given the measles-mumps-rubella vaccine at the appropriate age of 12 to 15 months, Barry said, he apparently was among the 5 percent of toddlers who fail to become immune from the first shot.

The booster shot given at 4 to 6 years of age raises the vaccine’s effectiveness from 95 percent to 99 percent, she said. No vaccine is 100 percent effective.

But vaccination remains the best way to prevent measles, said Dr. Sukhjit Takhar, an infectious disease specialist at Brigham and Women’s Hospital who recently treated two patients with suspected cases of measles that turned out to be something else. If a vaccinated child gets sick, the symptoms are usually less severe, he said. Measles can sometimes lead to pneumonia and, in rare cases, brain swelling, permanent brain damage, and death.

While this year’s surge in measles is worrisome, the chances of getting infected remain remote.

“Although this is the most cases we have seen of measles in five years, thankfully we have high levels of vaccination in Massachusetts, and we do not foresee a major outbreak,’’ said Julia Hurley, a spokeswoman for the Massachusetts Department of Public Health. What’s more, adults born before 1957 have natural immunity from having already been exposed to measles at at time before the measles vaccine was widely used.

Younger adults, however, may want to get a routine blood test from their doctor to see whether they still have antibodies to the measles. That is particularly important for women planning to become pregnant, because measles can increase the risk of miscarriage or premature labor. The CDC recommends that all adults ages 19 to 50 get immunized if they have lost their immunity.

The CDC also recommends getting infants above the age of 6 months immunized if they will be traveling to countries with significant measles outbreaks.

Deborah Kotz can be reached at dkotz@globe.com.

© Copyright 2011 Globe Newspaper Company.