History repeated itself Friday in ways that were grand and triumphant for Jamaica’s Usain Bolt and Allyson Felix and the U.S. women’s 400-meter relay team but were sourly familiar to the baton-passing-challenged U.S. men’s 400-meter relay.

Bolt sprinted off into retirement with an unprecedented triple-triple after anchoring Jamaica to victory in the 400-meter relay, the final flourish on a sweep of the 100- and 200-meter dashes and the short relay in Beijing, London and Rio.

His last public run might have been his dash toward the stands to share the moment with fans at a jubilant Olympic Stadium before he joined his teammates to dance and shimmy. If this was his farewell — and he repeated it was — what a way to go.

“There you go,” he said. “I am the greatest.”

No one could argue, even before he blazed past Aska Cambridge — the Jamaican-born anchor of Japan’s relay — to seal a win in 37.27 seconds. Japan was timed in 37.60.

The U.S. initially was declared third but was disqualified because of an illegal exchange outside the zone between leadoff runner Mike Rodgers and Justin Gatlin. Canada was elevated to third, with former USC star Andre De Grasse becoming a three-time Rio medalist as the anchor.

It was the ninth time since 1995 that a U.S. men’s relay team was disqualified or couldn’t get the baton around at an Olympics or world championship. It was an especially sharp dagger because Rodgers, Gatlin, Tyson Gay and Trayvon Bromell had posed for pictures with American flags draped on their shoulders and were celebrating when they were told they’d been disqualified. A spokeswoman said USA Track and Field had filed an appeal and expects a ruling early Saturday by the International Assn. of Athletics Federations’ jury of appeal.

“It was a Twilight Zone. It was a nightmare,” Gatlin said.

Rodgers said he thought the exchange was legal.

“I ran up on Justin. He never got the stick until he was inside the zone,” Rodgers said. “I knew it was early and that’s why I never let go of the stick because I know the rules. They thought it was early, but you could see he never had full possession until he was inside the zone.”

A lack of practice wasn’t to blame. The jubilant Jamaicans said Bolt had practiced exactly once with Asafa Powell, Yohan Blake, and Nickel Ashmeade.

The U.S. women’s 400-meter team had its own problems in its first-round heat Thursday but made the most of its second chance by winning the event for the second straight Olympics. Recovering from an apparent first-round disqualification that was reversed on appeal but consigned them to Lane 1 Friday, Tianna Bartoletta, English Gardner, Tori Bowie and Felix won in 41.01 seconds. Jamaica was second, in 41.36, with Britain third in 41.77.

Felix, a lifelong Los Angeles resident who attended USC, became the first U.S. woman to win five gold medals in track and field and she still has Saturday’s 1,600-meter relay left.

Wally Skalij / Los Angeles Times

Tianna Bartoletta and Allyson Felix, right, celebrate after winning gold in the women's 400-meter relay at the 2016 Summer Games.

She has won eight Olympic medals overall, making her the most decorated woman in U.S. track and field history, but her only individual gold came from the 200 in 2012. She lost the 400 here on a desperate but legal dive by Shaunae Miller of the Bahamas.

“It was just special. I felt like we were really strong tonight,” Felix said of the relay’s resilience. “The adversity made us even more determined and we just kept fighting all the way, through…. Sometimes adversity makes you stronger.”

The U.S. women’s 1,600-meter relay team of Courtney Okolo, Taylor Ellis-Watson, Francena McCorory and Phyllis Francis had the top first-round time — 3:21.42 — and qualified for Saturday’s final. Jamaica (3:22.38) had the second-best time. “Our goal was to come out and get a good lead for Phyllis because she was on the anchor and we wanted to make it to the final comfortably, and we did, so I’m proud of us,” McCorory said.

The U.S. men’s 1,600-meter relay finished second in its heat to Jamaica, which got a scorching anchor leg from Javon Francis. Arman Hall, Tony McQuay, Kyle Clemons and David Verburg were timed in 2:58.38, to Jamaica’s 2:58.29. “Our goal was to execute and make it to the final, and we did that,” Verburg said.

Defending Olympic pole vault champion Jenn Suhr, ill most of the week, finished seventh. However, U.S. teammate Sandi Morris won silver behind Greece’s Ekaterini Stefanidi, a former NCAA champion at Stanford who had fewer misses Friday at 4.85 meters (15 feet, 11 inches). Vivian Cheruiyot of Kenya set an Olympic record in the 5,000 at 14:26.17, ahead of Hellen Obiri of Kenya (14:29.77) and 10,000-meter champion Almaz Ayana of Ethiopia (14:33.59).

But the lasting memory will be Bolt’s unforgettable triple-triple swan song. “I hope,” he said, “I set the bar high enough that no one can do it again.”