Mustafina claimed gold with a score of 16.133, ahead of defending Olympic champion He Kexin's score of 15.933 with Tweddle's 15.916 earning her a spot on the podium as well.
It was an extremely poignant moment for Britain's most succesful gymnast Tweddle, who has three world, six European and seven British title to her name, as she competed in her last Olympic games.
Tweddle finished an agonising fourth in the uneven bars final four years ago in Beijing but went one better in London to earn her first ever Olympic medal and finish her glittering career in style.
He was first to compete and produced a near-perfect routine as an anxious Tweddle looked on.
It was slightly down on the Chinese's total in qualification but it set an impressive marker at the start of the final.
Victoria Komova, reigning world uneven bars champion who won silver in both the team and individual all-around, was next and scored a disappointing 15.666 despite a strong double-double landing after she caught the lower bar during her routine.
German Elisabeth Seitz, the last-place qualifier, moved into bronze medal position before China's Yao Jinnan overtook her and into silver with a score of 15.766.
Tweddle then stepped up to perform her routine to tremendous cheers from the home crowd.
The City of Liverpool gymnast produced a beautiful routine, brimming with complexity and with the maximum difficulty on her dismount, but needed to take a couple of steps on her landing after she struggled with the last rotation.
The judges scored Tweddle's routine down on her 16.133 qualification mark, which moved her into silver medal position behind He.
Mustafina then stepped up and produced a breathtaking routine, pushing He into silver and Tweddle down into bronze medal position with two gymnasts still to come.
Japan's Koko Tsurumi did not trouble to top of the leader board as she went seventh, before American Gabrielle Douglas took to the bars with Tweddle hanging on to bronze medal position.
Douglas made uncharacteristic errors during her routine to finish in last place.