Born in Swindon, Miley won 400 metres medley gold for Scotland in Delhi in 2010 and successfully defended her title when the Games came to Glasgow four years later as well as collecting bronze in the 200m medley.
She represented Great Britain at three Olympics from 2008 to 2016, narrowly missing out on a podium place when finishing fourth in the 400m medley in Rio.
Miley took 400m medley silver at the 2011 World Championships in Shanghai, having claimed European gold in the same event in 2010. She also boasts one silver and three bronze European Championship medals.
She won 400m medley gold at the 2012 World Short Course Championships in Istanbul, having secured silver in the 400m and bronze in the 200m medley in Manchester four years previously, and was crowned 400m medley champion at the European Short Course Championships in 2009 and 2012.
"While this is difficult to write I've have made the big decision to announce my retirement from swimming, well competitively at least," Miley said on Twitter.
"It's a sport that I will always love and whilst I will be hanging up my racing suit, my goggles will remain in my hand.
"I remember being an eight-year-old swimmer desperate to go to the pool, 24 years later that feeling hasn't changed.
"Three Olympic Games, double Commonwealth champion, world and European Champion, European record-holder. To stand on the podium and listen to the national anthem for both Great Britain and Team Scotland is indescribable. It's been one hell of a ride.
"I've met and worked with so many wonderful people and would like to thank them all for their time and support. You all know who you are.
"There is one person that I need to thank, my dad. His ingenious ability to think outside the box and groundbreaking analysis has taken my family aka 'Team Miley' on the most incredible journey."
Miley still holds the British record in the women's 400m individual medley.
"Reflecting on my career, I look back with pride and a smile as I feel like I have achieved everything I possibly could over the last 17 years of international racing," she added.
"Whilst the Olympic medal eluded me, I still feel satisfied I couldn't have given it anymore.
"I will always be 'Smiley Miley' and can't wait to see what the world has in store for me next."
British Swimming national performance director Chris Spice said: "Hannah has been a fantastic, long-serving ambassador for British Swimming, with world and European medals to her name, as well as appearances in finals at three successive Olympic Games.
"On top of that, she was a fantastic leader and a role model for younger athletes too.
"We wish her all the best for the future and whatever she goes on to do next."
Miley is the second high profile British sportswoman to retire on Wednesday, with Wimbledon semi-finalist Johanna Konta also calling time on her tennis career.