This picture taken on April 5, 2019 shows a nurse preparing the measles, mumps and rubella vaccine at the Rockland County Health Department in Haverstraw, Rockland County, New York.

New York City on Tuesday declared its recent measles outbreak a public health emergency and ordered mandatory vaccinations for people living in areas where the disease is spreading.

Residents of Brooklyn's Williamsburg neighborhood have 48 hours to get the measles, mumps and rubella (MMR) vaccine or face a $1,000 fine, Mayor Bill de Blasio announced Tuesday. The outbreak has sickened 285 people in the city since October and its spread has picked up pace over the last two months, officials said.

"Measles is a dangerous, potentially deadly disease that can easily be prevented with vaccine," said Dr. Herminia Palacio, deputy mayor for Health and Human Services. "When people choose not to get their children vaccinated, they are putting their children and others — such as pregnant women, people on chemotherapy, and the elderly — at risk of contracting measles."

The neighborhood is home to a large Orthodox Jewish population. Some of them have refused to vaccinate their children, leaving the tight-knit communities vulnerable to the highly contagious disease. In response to the outbreak, the city on Monday threatened to close Jewish schools that allow unvaccinated children.

For more on investing in health-care innovation, click here to join CNBC at our Healthy Returns Summit in New York City on May 21.

Health officials traced the first case of this outbreak back to unvaccinated people who traveled to Israel, where there is currently a large outbreak.

New York City's measles outbreak is one of a number across the country. An outbreak also has been reported in suburban Rockland County, New York. So far this year, 465 cases have been confirmed, the second-highest amount since the disease was declared eradicated from the U.S. in 2000, according to the Centers for Disease Control and Prevention.

Measles is highly contagious, infecting up to 90 percent of unvaccinated people who are exposed to it, according to the CDC. The virus can live in the air for up to two hours after an infected person coughs or sneezes, according to the CDC, meaning people can be exposed to it without ever knowing. People can be infected for days before showing signs of the virus, such as a fever, runny nose or a rash.

Measles can be especially dangerous for young children, the CDC says. It can lead to pneumonia, brain swelling and even death.