The incident happened on a flight from Denver to Minneapolis on Sunday morning, activist Shannon Watts said.
United said the girls were travelling on a special pass, for employees and their guests, which has a dress code.
It has since clarified that all regular, paying customers are welcome to wear leggings.
The girls were "United pass travellers", which are tickets for company employees or eligible dependents, it explained in a Twitter exchange on the issue.
"United pass travellers" are eligible for free or heavily discounted air travel.
The dress code for pass-holders states they should not wear "form-fitting lycra/spandex tops, pants and dresses", among various other stipulations, including no exposed midriffs, no mini skirts and no flip-flops.
Why are leggings so controversial?
Activist Shannon Watts tweeted about what happened to five girls when they tried to board a flight at Denver airport.
She said a United gate agent was "forcing" the girls, one of them aged 10, to change their clothes or wear dresses over the leggings.
She said three of the girls were allowed to fly after putting dresses over the top of their clothing, but two were prevented from boarding.
She criticised the airliner for its actions, asking: "Since when does United police women's clothing?".
United later released a statement explaining the dress code requirement of its United pass travellers.
"When taking advantage of this benefit, all employees and pass riders are considered representatives of United. And like most companies, we have a dress code that we ask employees and pass riders to follow," it said.
It added that the passengers on Sunday's flight had not complied to the dress code.
Ms Watts' tweets have been shared and responded to by thousands of users, including the actress and activist Patricia Arquette.
Flight attendant and author Heather Poole, who does not work for United, defended the airline's policy on Twitter.
She said dress codes for staff travelling on free passes are common practice in the industry, and have evolved over the years.
Get news from the BBC in your inbox, each weekday morning
United Airlines has been heavily criticised on social media after two girls were reportedly barred from flying for wearing leggings.