By Pritha Sarkar

RIO DE JANEIRO (Reuters) - Ukrainian Oleg Verniaiev made up for narrowly missing out on the all-around gymnastics title by winning the parallel bars gold at the Olympics on Tuesday.

Verniaiev, who came agonizingly close to ending the all around reign of Japan's Kohei Uchimura before missing out on gold by just 0.099 of a point, finally got his hands on the top prize by winning the bars with a score of 16.041.

He beat American silver medalist Danell Leyva by 0.141 of a point. Russia's David Belyavskiy had to settle for bronze.

World champion You Hao and Deng Shudi completed a forgettable Olympics for the Chinese men's gymnastics team as they will leave Rio without a top prize after both finished out of the medals.

But there was no doubting who was number one as Verniaiev waved a raised index finger to the crowd long before the judges confirmed his score, giving Ukraine its first gold medal at these Games.

"At last we've brought the first gold medal to Ukraine. It's been cool and I still can't relax, I'm so thrilled," said Verniaiev, who missed out on a chance to win a third medal when he landed on his hand and knees from his horizontal bar dismount.

"I knew the two Chinese were very strong, Leyva was strong, but basically you just go out and do your thing."

Traveling the bars end-to-end, Verniaiev swung into a series of handstands. Such was the difficulty packed into his routine that he managed to breach the 16-point barrier despite his legs wavering considerably on one of the handstands.

Once he nailed his dismount, he fell into the arms of his delighted coach.

However, it was Leyva's stepfather and coach, Yin Alvarez, who provided the real entertainment with his theatrical celebrations on the final day of competition.

Alvarez wildly sprinted up and down the dugout with a raised fist as soon as Leyva had completed his routine with a double front dismount. But with seven more competitors to go after Leyva, Alvarez faced an anxious wait to see if his stepson's score of 15.900 would be good enough for a medal.

Once he realized it was, he was off sprinting again along the dugout.

Alvarez's joy was in sharp contrast to the utter dejection felt by world champion You.

His routine had the highest difficulty rating of 7.400 among the eight finalists and when he swung into 10 rigidly straight handstands, it seemed as if he would finally end China's wait for a gymnastics gold in Rio.

But after launching into his double front somersault with half twist dismount, he crouched down on his landing before his feet simply gave away and he fell backwards.

All his hard work amounted to nothing and he finished last with 14.833. Deng missed out on bronze by 0.017 of a point.

Deng summed up China's misery.

"I don't know what happened. My brain is empty," he said.

The nation that captured seven out of eight men's golds in Beijing eight years ago will be leaving Rio with a solitary bronze medal they won in the team competition. Their female counterparts also won only one team bronze.

Since returning to the Olympics in 1984, it was the first time the Asian powerhouse failed to win a gymnastics gold.

(Editing by Jan Harvey and Ed Osmond)