PUERTO MORELOS, Mexico—Mexico’s Yucatán Peninsula is famous for its aquamarine waters, white sandy beaches and Mayan ruins. But it is fast gaining a reputation as a destination for something far less appealing: rotting seaweed known as sargassum.

For several years, growing amounts of the thick macroalgae have washed up on the shores of resorts including Cancún, Playa del Carmen and Tulum, turning water brown, blanketing beaches and releasing a pungent smell as it decays in the sun.

This...