MPs approved a law - by 131 votes to 117 - that would legalise elective abortions to the 14th week of pregnancy.