United Airlines barred two teenage girls from boarding a flight on Sunday morning and required a child to change into a dress after a gate agent decided the leggings they were wearing were inappropriate. That set off waves of anger on social media, with users criticizing what they called an intrusive, sexist policy, but the airline maintained its support for the gate agent’s decision.

The girls, who were about to board a flight to Minneapolis, were turned away at the gate at Denver International Airport, the company said on Sunday. United doubled down on that decision, defending it in a series of tweets on Sunday.

The incident was first reported on Twitter by Shannon Watts, a passenger at the airport who was waiting to board a flight to Mexico. In a telephone interview from Mexico on Sunday afternoon, Ms. Watts said she noticed two visibly upset teenage girls leaving the gate next to hers. Both were wearing leggings.

Ms. Watts went over to the neighboring gate and saw a “frantic” family with two young girls, one of whom was also wearing leggings, engaged in a tense exchange with a gate agent who told them, “I don’t make the rules, I just enforce them.”