David Horowitz scored a try in the final minute to give the Waratahs a thrilling 32-25 win over the Rebels in Melbourne.