With 68 points separating the top two going into the final 800 metres event, Brianne Theisen-Eaton needed to finish 4.69 seconds ahead of Melnichenko to take gold but the Ukrainian shadowed her rival round the two laps.
The 30-year-old collapsed on the track after crossing the line and held her head in disbelief as the final result flashed up, bringing the hundreds of Ukrainians in the crowd, easily recognisable in bright blue and yellow T-shirts, to their feet.
World junior champion Dafne Schippers of the Netherlands charged down the home straight to finish third and secure the bronze medal with a national record of 6,477, an effort that left her needing to be helped off the track by officials.
Johnson-Thompson needed to make up three seconds on Schippers but despite a second place finish, she couldn’t overhaul her Dutch rival for the bronze medal.
Melnichenko finished the seven events with a personal best total of 6,586 points, 56 more than Theisen Eaton, who was given a congratulatory hug at the finish by her husband and world decathlon champion Ashton Eaton.
The pair, who married last month, are the first husband and wife to win medals in a global combined-event competition.
"I watched Ashton the last couple of years winning all his medals and could only sit back and imagine what that felt like," the 24-year-old said.
"After the 800-metres he just said to me 'good job and enjoy your victory lap'.
"We'll probably just go home now, sit on the couch for a few days watching television and eating crappy food."
Melnichenko told reporters: "I realised that I could win after the javelin throw.
"The time between the javelin and the 800 metres was the most exhausting time ever."
Olympic champion Jessica Ennis-Hill of Britain and Russia's defending world champion Tatyana Chernova missed the event due to injury.