Gold Coast, Australia American teen wonder Katie Ledecky claimed her second world record of the meet and Olympic titan Michael Phelps lost a thrilling medley final on a dramatic closing night for the Pan Pacific Championships on Sunday.

Ledecky, 17, set her second world record in two days by smashing her own 1500-metre freestyle record on the way to claiming a fifth gold at the Gold Coast meet.

But her celebrated American teammate Phelps went down by two-hundredths of a second to Japanese Kosuke Hagino in the 200-metre individual medley final, denying him his second individual gold medal of the event.

Phelps, the all-time greatest Olympian with 18 gold medals, was pipped by Hagino in a desperate finish to the event he has won three times at the Olympics.

Ledecky finished the swimmer of the meet with an astonishing world record swim of 15 minutes 28.36 seconds, carving almost six seconds off the old mark she set in June.

Ledecky won the 200, 400, 800 and 1500 metres freestyle golds at the Pan PACs and was also part of the American women’s winning 4x200-metre freestyle relay team.

“I knew it was my last race of the meet and the last race of the season and I wanted to finish a really good season on a good note,” she said.

“It was probably one of my most painful races. It was painful, but it pays off in the end, so I’m happy.”

Ledecky, the dominant freestyler in world swimming, now holds the world records in the 400, 800 and 1500 metres freestyle, making her the first woman since US distance great Janet Evans to hold all three records at the same time.

“I am really enjoying the journey and just enjoying each step, so hopefully there are a few steps left,” she said.

Phelps was overhauling Hagino in the final lap of the 200-metre medley after trailing the Japanese by 0.66 secs at the final turn, but Hagino managed to hang on for a prestige win over the greatest Olympian.

“My goal was to do my best. However, I believe Michael Phelps is not in his best condition, so I am pleased that I did my best and won the race,” Hagino said through a translator.

Phelps said he should have gone faster in the first half of the race, but he had accomplished all his goals at his first international meeting since a 20-month break following the London Olympics.

“Today my body was hurting. I woke this morning and my body was in pain,” he said.

“But after this morning’s race and a nap I felt pretty fresh, I felt good.

“During the warm-up I felt a little poppy [edgy] and the one thing if I look back at tonight’s 200IM [individual medley] and say if I would change anything, it would probably be to step on the first 100 metres.

“I think for my first real international meet back we accomplished everything we wanted to.

“We were able to find out some of the things that I need to improve on over the next year and things I want to improve on.”

The victory crowned an outstanding Pan PACs for the 20-year Hagino, who was a bronze medallist behind Ryan Lochte in the 400-metre individual medley at the 2012 London Olympics.

Hagino completed the medley double at the Pan PACs after winning the 400-metre event from another American Tyler Clary on Friday.

Japan capped a successful night with other gold medals in both 200-metre breaststroke finals with Kanako Watanabe (2:21.41) in the women’s event and Yasuhiro Koseki (2:08.57) in the men’s.

Other winners were America’s Maya Dirado (women’s 200-metre medley), Australia’s Cate Campbell (50-metre freestyle), Canada’s Ryan Cochrane (men’s 800-metre freestyle) and Brazilian Bruno Fratus (men’s 50-metre freestyle).

Phelps won his third gold medal of the meet as part of the American men’s winning 4x100-metre medley relay over Japan, while Australia took the women’s 4x100-metre medley relay.

The United States finished top nation with 14 golds from hosts Australia with ten, Japan with seven and South Korea, Canada and Brazil with one each.