Scorers: Motherwell - Law (9, 19); Stjarnan - Finsen (pen 35, pen 90)
Law, who started just off John Sutton in his first appearance since a summer move from Conference side Alfreton Town, showed early promise in his bid to emulate brother Nicky’s impressive two-year spell at Fir Park as he finished twice after getting ahead of the visiting defence.
Motherwell were well on top until the 35th minute when Olafur Karl Finsen converted a penalty after Keith Lasley was adjudged to have handled.
And they suffered a huge blow in injury-time when Finsen netted again after Craig Reid was ruled to have pushed over Rolf Toft as Motherwell scrambled to defend a counter-attack.
The hosts might have had a penalty themselves seconds earlier when Simon Ramsden went down as he looked set to score following a corner.
Stjarnan, who sit second in the Icelandic League after 11 unbeaten games, have the advantage of playing on their own artificial pitch for the second leg of the Europa League second qualifying round.
The visitors had hinted they would sit in, but they pushed four men forward when attacking and Motherwell had a let-off inside four minutes when the unmarked Veigar Pall Gunnarson sent a diving header wide from six yards after the visitors had broken away from defending a corner.
Motherwell forced several more corners and their pressure paid off in the ninth minute as Law scored their first goal in eight European games.
Lasley chipped a cross in for John Sutton, whose header was palmed out by Ingvar Jonsson, and Law had the simple task of knocking it over the line from close range.
Motherwell kept attacking and the second goal came after right-back Niclas Vemmelund slipped on the touchline to concede possession to Iain Vigurs.
Vigurs cut in and played a perfect reverse pass for Law, who dinked the ball over the goalkeeper.
Stuart Carswell should have made it three when Sutton rolled the ball back to him 14 yards out, but the midfielder blazed over.
The visitors were handed a lifeline when Lasley was penalised by Danish referee Michael Johansen as he tried to block a shot with his chest.
Lasley did not protest much as he was booked and Finsen sent Dan Twardzik the wrong way from the spot to the delight of the 22 visiting fans.
Lasley almost made amends by setting up Sutton two minutes later following a one-two with Steven Hammell, but the Englishman shot just wide from 16 yards.
Motherwell finished the half nervously. Reid cleared the danger after some risky defending almost allowed Finsen in, but the right-back then dived in to allow Stjarnan to break and Twardzik got down well to save from Arnar Mar Bjorgvinsson.
Stephen McManus saw a powerful strike saved well after the restart, but Motherwell had another huge scare when Finsen volleyed wide from four yards following a cross from the right.
Vigurs slotted home after a one-two with Law, but a strange offside decision scuppered the celebrations with the flag presumably going up against Sutton, who did not touch the ball.
Finsen came close again with an angled strike from 20 yards and right-winger Bjorgvinsson was causing problems.
But Motherwell had chances to get a two-goal cushion and Jonsson saved well from Lasley before substitute Lee Erwin headed over.
And the injury-time drama nudged the game in Stjarnan’s favour.
Motherwell: Twardzik, Reid, Hammell, Ramsden, McManus, Carswell, Vigurs, Lasley, Law (Kerr 70), Ainsworth (Erwin 70), Sutton. Subs not used: Nielsen, McHugh, Leitch, Thomas, Cadden.
Stjarnan: Jonsson, Vemmelund, Laxdal, Arnason, Rauschenberg, Praest, Johannsson, Punyed, Gunnarson (Toft 88), Bjorgvinsson, Finsen. Subs not used: Svinn Johannesson, Aegisson, Heiddal, Runarsson, Ottesen Palsson, Blondal.