Ariarne Titmus said staying composed was the key to her victory over Katie Ledecky in a captivating women's 400 metre freestyle final.

In what was billed as one of the races of Tokyo 2020, both women produced a performance straight out of the top drawer in a battle that went down to the wire.

World champion Titmus was back by around six lengths at one stage as Ledecky stormed out of the blocks.

The American world record holder, who set her benchmark when winning gold at Rio 2016, would be reeled in by a determined Titmus, though, and the Australian held on to win a thriller.

"Honestly, at the 200 metre [mark] I was a bit worried, but I did not come to the Olympic Games unprepared," said Titmus, who became the third Australian woman to win gold in the event, after Lorraine Crapp and Shane Gould.

"I had to trust myself and stay as composed as I could. Use the speed that I have. And all that against a woman who has an amazing back end of her race. I'm really proud."

Titmus is also slated to race in the 200m and 800m free races at Tokyo 2020 and says the celebrations are on hold for now.

"It is the biggest thing you can pull off in your sporting career, so I'm over the moon," she added.

"I'm trying to contain it as much as I can. I have a big programme ahead of me, but I can enjoy this afterwards."Ariarne Titmus

Ledecky had never been beaten in an individual Olympics race and swam her second ever fastest time in the 400m free.

The American concedes her rival was just better on the day.

"She definitely swam a really smart race. She was really controlled up front," Ledecky said.

"I felt smooth and strong. I looked up at 300m, and she was right there, so I knew it would be a battle to the end. I didn't feel like I died or really fell off. She just had a faster final 50 or 75m and got her hand to the wall first."

When asked if this was her toughest race, Ledecky, a five-time Olympic gold medallist, replied: "I guess.

"I've had some tough ones over the years. It was certainly a tough race and I delivered. I couldn't do much better than that.

"It was a tremendous race, a lot of fun. I can't be too disappointed. It was my second-best swim ever (over 400m freestyle). I felt like I fought tooth and nail and that's all you can ask for."