WASHINGTON — Melania Trump was booed by a roomful of students in Baltimore on Tuesday when she took the stage to give a speech about youth opioid use, one of the pillars of her “Be Best” initiative.

A vocal crowd of middle school and high school students erupted in a mix of loud boos and some cheers as the first lady strode across the stage at the B’More Youth Summit on Opioid Awareness.

Mrs. Trump smiled through the unpleasant welcome, even as members of the crowd talked over her speech. “I’m in this fight for you, and I’m fighting for you,” Mrs. Trump said. “If you are struggling with addiction right now, reach out for support.” She encouraged the students to “talk to an adult in your life that you trust. It is never too late to ask for help.”

Mrs. Trump’s visit to Baltimore came just four months after President Trump dismissed the city as a “disgusting, rat and rodent infested mess” where “no human being would want to live.” He had maligned the city in a Twitter diatribe aimed at former Representative Elijah E. Cummings, a Democrat from Maryland who was a leading critic of the president. (Mr. Cummings died in October.)