Scottish Premier League Roundup, Feb. 19
At Tynecastle, Hearts fought back from a goal down, scoring their winner two minutes from time, but even then the visitors had a chance to earn a point, only to miss an injury-time penalty.
United took an early lead in Edinburgh through Barry Douglas before Rudi Skacel levelled just before half-time.
Hearts then left it late again in the second half as a header from Marius Zaliukas - his first goal of the season - proved to be decisive, with David Goodwillie denied from the spot by keeper Marian Kello in the final seconds.
Hearts are now two points behind Rangers, who face leaders Celtic on Sunday although they have played three games more.
Elsewhere, Aberdeen smashed five without reply past a shambolic Kilmarnock at Pittodrie.
The Dons broke the deadlock when Scott Vernon's shot squeezed past Cameron Bell after 15 minutes before Sone Aluko added a second with a low drive 10 minutes later.
Chris Maguire netted a third from the spot after 59 minutes after he had been brought down in the box by Frazer Wright before Rory McArdle scored the fourth from close range with 19 minutes remaining.
Substitute Josh Magennis added a fifth in the closing stages.
Inverness ended an 11-game run with a league win by beating St Johnstone 2-0 at home.
Rare goals from Ross Tokely and Russell Duncan gave the Highlanders their first SPL victory since November.
Tokely's powerful header from five yards opened the scoring after 28 minutes before Duncan sealed the victory with a close-range tap-in in the 62nd minute.
Motherwell kept up their push for a top-six place with a 1-0 home win over basement dwellers Hamilton.
Accies had a chance to close the gap on drop rivals St Mirren and Hibs - they meet each other on Sunday - but they fluffed their lines.
John Sutton's penalty settled the clash and the result means Hamilton remain five points drift at the foot of the table.