Japan edged out the USA and Romania to win their first gold medal in the team gymnastics competition since 1976.
Romania had taken a tiny lead into the final event, but their bid ended when Razvan Selariu fell off the high bar.
Each of the Japanese gymnasts performed brilliantly on the final piece of apparatus to clinch overall victory.
World champions China could only manage fifth place behind Korea, their day summed up when Teng Haibin also took a tumble on the high bar.
The consistency of the Japan team performance recalled the country's golden years, when they won this event five times in a row between 1960 and 1976.
But the USA and Romania made big contributions to an entertaining final as well.
Romania led for much of the night, before falling victim to nerves at the end.
The Americans applied pressure by posting solid scores on the last event, but the Japanese would not be denied.