The bright yellow dispenser caught Byvian Mercado’s eye.

“I honestly thought it was hand sanitizer,” Ms. Mercado, 41, said on Monday of the machine filled with sunscreen at Orchard Beach in the Bronx. “It’s a great idea,” she said about the dispenser in the restroom. “I wish there was some sort of a sign on the wall.”

New York City has placed 100 sunscreen dispensers at 27 locations at nine beaches and one fishing pier.

The free sunscreen is part of a pilot program adopted by the Parks Department to help prevent skin cancer. It was proposed a year ago by the city comptroller, Scott M. Stringer, and began when the beaches opened over the Memorial Day weekend. Similar programs already exist in Boston and Miami Beach.

“This is big — it will help New Yorkers from across the five boroughs protect themselves. We’re proud that our report laid the groundwork for this becoming reality,” Mr. Stringer said in an email message.