Dirk Nowitzki hit a game-winner with two seconds left to push Dallas past the Lakers after a back-and-forth affair.