Italian Prime Minister Matteo Renzi announced his resignation hours after learning he had suffered a crushing defeat in a referendum on constitutional reform.