MPs approved the amendment to the Crime and Policing Bill put forward by Labour's Tonia Antoniazzi by a majority of 242 with 379 in favour and 137 against.
Speaking during the debate, Antoniazzi said: ‘Originally passed by an all-male Parliament elected by men alone, this Victorian law is increasingly used against vulnerable women and girls.'
Current laws in England and Wales state abortion is illegal but allowed up to 24 weeks and after that if the woman's life is in danger.
The law change would mean that women who terminate their pregnancy outside 24 weeks no longer face the risk of being investigated by the police.
The amendment was backed by Royal College of Obstetricians and Gynaecologists (RCOG).
Professor Ranee Thakar, president of the RCOG, said: ‘This is a victory for women and for their essential reproductive rights.
‘This sends a powerful signal that women's rights and autonomy matter. The college has been campaigning to see this achieved for many years, and the decision reflects the voices of over 50 medical, legal and public health organisations. It also reflects the views of the public, who overwhelmingly support the right of women to access abortion care safely, confidentially, and without fear of investigation and prosecution.'