CAIRO  - Egypt's parliament on Monday passed a law that could make senior military officers immune from future prosecution over to violence that followed the 2013 ouster of Islamist president Mohamed Mursi.

The law gives President Abdel Fattah al-Sisi the right to name officers to be eligible for immunity from investigation into alleged offences committed while Egypt's constitution was suspended between Mursi's overthrow on July 3, 2013 and the reconvening of parliament on Jan. 10, 2016.

The law, submitted to parliament as recently as the end of June, also makes those named by Sisi reserve officers for life and accords them wide-ranging privileges, including diplomatic status when travelling abroad.

Any legal measures or investigation against such officers for actions committed over that period in the line of duty would require clearance from the Supreme Council of the Armed Forces, the law states.

In one of the bloodiest events in Egypt's recent history. hundreds were killed when security forces broke up a sit-in at Cairo's Rabaa Square in support of Mursi in August 2013. He was removed from office after mass protests against his rule.

Egyptian authorities have defended the security forces' actions, saying protesters were given the opportunity to leave peacefully and that armed elements within Mursi's Muslim Brotherhood group initiated the violence.

After speeding through a legislative process that typically takes months, the law was passed by a show of hands in parliament with an overwhelming majority of attending lawmakers raising their hands in support. A Reuters reporter counted eight MPs voting against it.

(Reporting by Cairo bureau; Editing by Toby Chopra and John Stonestreet)