Katy Perry and Miley Cyrus paid tribute to the music and legacy of Dolly Parton in a special performance at the Grammy Awards.

Cyrus, the goddaughter of the veteran country star, was joined by fellow pop star Perry on stage at the star-studded event in Los Angeles.

Performing alongside neo-country singers Kacey Musgraves and Maren Morris, they took on a medley of tracks made famous by Parton.

But in a twist they were joined by the country legend herself, who sang against a backdrop of starry skies.

Parton, 73, defied her age to belt out her classic songs Here You Come Again, Jolene and 9 To 5.

She was joined by Cyrus and Morris for a cover of Neil Young’s 1970 hit After The Gold Rush, but re-worked the lyrics to send an environmental message fit for the modern day.

The trio sang of having “Mother Nature on the run in the 21st century”, rather than the 1970s originally envisioned by Young.

61st Annual Grammy Awards – ShowDolly Parton performs with Little Big Town (Matt Sayles/Invision/AP)

Parton was then joined by more musicians, including Jimi Westbrook, Kimberly Schlapman, Karen Fairchild and Philip Sweet of Little Big Town, a popular US country group.

Pitch Perfect actress Anna Kendrick introduced the surprising line-up, saying: “The great singer, songwriter, actress and enduring superstar we are about honour once said: ‘If you don’t like the road your walking start paving another one’.

“That’s how this remarkable woman has been blazing her own trail year after year, decade after decade, and that’s why we will always love her.”

The group were backed by an eight-piece country-style band, which included a steel pedal guitar player and backing vocalists.