By Joshua Schneyer

RIO DE JANEIRO (Reuters) - U.S. gymnast Gabby Douglas turned in a near flawless performance at Sunday's Olympic qualifying event, gaining the third highest score of any gymnast, but because of Olympic rules she will not be going to the all around final.

That means Douglas will not have the chance to defend the gold medal she won at the all around women's gymnastics event at the 2012 London Games.

Olympic rules limit to two the number of gymnasts from any one country who can advance to the all around final. In Sunday's qualifying event, Douglas' team mates Simone Biles and Alexandra Raisman turned in higher scores as the U.S. women dominated the competition.

"I would have loved to go out there and defend my title, but I'm not disappointed," Douglas told reporters. "It's been an amazing ride."

Since winning the all around gold in London, there have been doubts Douglas could regain her Olympic form. She took a two year break, wrote a biography, starred in a reality TV show, and switched coaches.

She dispelled those doubts on Sunday, turning in rock solid performances in all four gymnastics apparatuses: floor exercise, balance beam, uneven bars and vault.

Only Biles, the three-time all around world champion who is appearing at her first Olympics, and Raisman, a gold medal winner in the floor exercise at the London Games, scored higher.

In the all around final on Thursday, a total of 24 competitors will be scored in all four events.

Raisman narrowly edged out Douglas for that honor on Sunday.

DOUGLAS PROVES HER PLACE ON TEAM

History shows it is exceedingly difficult for gymnasts to win an all around gold twice. It was last done in 1968, by Vera Caslavska of Czechoslovakia.

Douglas will still play a key role in the team competition, where the United States women are favorites to repeat their gold medal win in London. She also qualified as one of eight finalists in the uneven bars competition.

For Douglas, just getting to Rio was not easy, and the decision to allow her onto the five-woman U.S. team was a controversial one.

At the U.S. trials in July, she put in a series of shaky performances, including falling off the beam. She placed seventh overall by points there.

National team coordinator Marta Karolyi selected her for the U.S. Olympic team anyway, expressing confidence that she would shine in Rio.

"I think Gabby just proved that she has a place on this team," Karolyi told reporters in Rio. "I know our decision was very much questioned."

Raisman said it was unfortunate that Douglas would not get a chance to defend her London title.

"I hate the two-per-country rule," Raisman said. "I wish they would change that."

The rule came about to prevent one country's gymnasts from dominating the Olympic podium, as Romania's women had at the Sydney Games in 2000, where they won gold, silver and bronze medals in the all around event.

Gymnast Andreea Raducan of Romania was later stripped of her Sydney gold medal, after she tested positive for a banned substance.

(Reporting By Joshua Schneyer; Editing by Andrew Hay)