Odense looked to have inflicted a fatal blow to Well's hopes after Peter Utaka caught them on the break in the 78th minute to add to Chris Sorensen's soft first-half opener.
Steve Jennings was then sent off but Hateley curled into the top corner from 25 yards with a re-taken free-kick to send the 500 travelling fans into delirium.
The goal was the least Motherwell deserved for an attacking display which saw them enjoy as much territory and possession as their hosts.
Well boss Craig Brown played the whole second half with three up front despite initially changing his formation to a 4-4-2 with Chris Humphrey on the left wing and John Sutton playing just off Jamie Murphy.
Odense started with former Manchester United pair Roy Carroll and Eric Djemba-Djemba.
Murphy was handed a good chance to test Carroll after 30 seconds when he pounced on a loose pass but the Scotland Under-21 international shot wide from 18 yards.
Odense soon created a better chance when left-back Sorensen's cross found Atle Roar Haland six yards out but the centre-back headed over.
Mark Reynolds was harshly booked for a high challenge on Caca but Motherwell soon posed problems going forward.
Humphrey came inside and played a reverse pass in front of Murphy, whose shot was diverted wide. The English winger crossed moments later when he might have been better shooting.
Hateley and Sutton both shot over from long range but the hosts looked capable of stretching Motherwell when they moved the ball around quickly in the final third and Darren Randolph made a good block midway through the half.
The former Charlton goalkeeper beat away Johan Absalonsen's shot after the Denmark midfielder ran on to Utaka's threaded pass.
Randolph was tested again by Absalonsen soon after before Hateley came closer with a 20-yard free-kick.
But Motherwell's promising start was undone in the 31st minute.
Hungarian referee Zsolt Szabo waved play on after Caca fell under Stevie Hammell's challenge but changed his mind after his assistant flagged.
Sorensen swung the free-kick from 30 yards out on the right towards the edge of the six-yard box but the ball went straight into the far corner.
Motherwell put their hosts under some pressure before the break but their delivery let them down and Szabo waved away penalty appeals when Sutton's header appeared to hit Anders Moller Christensen on the arm. Odense replaced Caca with midfielder Henrik Hansen and Brown reverted to a 4-3-3 formation with Humphrey moving to the right.
The hosts were inches away from a second when Rurik Gislason fired just beyond Randolph's far post after beating Lasley and Jennings, who was soon booked for leading with an elbow.
Motherwell were soon on the offensive though, forcing several corners and feeding Humphrey at every opportunity, although the winger's crossing did not match his approach play.
Sutton closed down Carroll after a short header back but the ball fell kindly for the home side.
Motherwell continued to press and Humphrey cut inside Sorensen following Hammell's diagonal ball but his left-foot shot lacked power.
Murphy claimed strongly for a penalty after being nudged off balance by Espen Ruud while trying to volley from 16 yards.
The striker soon made way along with Lasley as Brown brought on Nick Blackman and Ross Forbes.
Motherwell were almost caught on the break as Gislason headed wide and they were exposed when Utaka beat Stephen Craigan for pace to reach a forward pass and rounded Randolph before lashing past three Motherwell players into the roof of the net.
Saunders was booked for a body check before Hansen had a great chance to kill off the tie but sliced Utaka's cut-back over from 15 yards.
Forbes had a free-kick saved before Jennings received a second booking three minutes from time when he caught Ruud late.
But the 10 men stunned their hosts deep in injury-time when Hateley curled a glorious 25-yard free-kick into the top corner.
Hateley's first effort, after Blackman had been hauled down by Hans Henrik Andreasen, had gone straight into Carroll's hands.
But the midfielder was allowed to take another after the referee blew his whistle in the act of shooting amid some jostling in the box, and the Englishman took full advantage with virtually the last kick of the ball.