Did God Approve of Rahab’s Lie?

How can lying be “an abomination to the Lord,” while at the same time God commended Rahab twice in the New Testament? Are God and His law on lying contradictory? And can the story of Rahab logically be used as a license to lie?