CAIRO (Reuters) - Four children were killed and five other people were injured when a rocket landed near their homes in Rafah, an Egyptian town in Sinai near the border with Gaza, security officials said on Saturday.

Three security sources said the rocket was likely fired by Islamist militants operating in the Sinai peninsula, which borders Israel and the Palestinian Gaza Strip.

The state news agency MENA said security officials were still investigating where the rocket had come from.

Egyptian security forces have been struggling for years to quell an Islamist insurgency that has killed scores of soldiers and policemen in Sinai. The attacks surged after the army overthrew Islamist president Mohamed Mursi last year and the militants extended their reach to Egypt's mainland with a series of bombings, prompting the army to intensify its attacks on them in Sinai.

The three security sources said the rocket fired on Saturday had been targeting an army compound or check point but had fallen instead by mistake near civilian homes.

The rocket was fired from al-Gorah city, which is 10 kilometers away from the Gaza border, one security source said. The Egyptian army said earlier on Saturday it had killed 12 militants in its most recent operation in Sinai.

Across the border in the coastal enclave of Gaza, which is controlled by Hamas Islamists, the number of Palestinians killed in a 19-day war with Israel topped 1,000 on Saturday.

(Reporting by Ali Abdelaty and Yusri Mohamed and Yasmine Saleh; Editing by Gareth Jones)