Five Egyptian diplomats who were abducted by militants in the Libyan capital Tripoli have been freed, Libyan Deputy Foreign Minister Abdul Razak al-Grady has said.