By faith he forsook Egypt, not fearing the wrath of the king: for he endured, as seeing him who is invisible.
He left Egypt because of his faith and wasn't afraid of the king's anger. He could do this because he saw, in his mind, someone unseen who was supporting him.