Gunmen armed with rocket-propelled grenades attacked a border guard post Saturday in Egypt’s western desert near Libya, killing at least 20 troops, security officials and a medic said.

An Interior Ministry official and a military official said the gunmen targeted a checkpoint in the western desert governorate of Wadi el-Gedid, on the Farafra Oasis Road, more than 500 kilometers (310 miles) from Cairo. Farafra is the country’s western most oasis, near the border with Libya.

The military official said about 20 gunmen in weapon-mounted vehicles took the checkpoint by surprise. Ensuing clashes killed three of the attackers, the officials and the state news agency MENA said.

Initially, officials said 15 troops were killed. But a senior military official in southern Egypt and a security official in the region said 20 were killed in an attack that destroyed the checkpoint. A medic with the local ambulance service said there were 21 bodies, some of them burned. Another medic said a local hospital treated five of the wounded.

The officials and the medic spoke on condition of anonymity because they were not authorized to speak to journalists.

MENA said this is the second time this border patrol company has come under attack from gunmen in the last few months. An earlier attack killed six troops, the agency said.

Egypt has long, porous borders with Sudan and Libya used by arms smugglers. Egypt has been flooded with weapons, mostly from Libya, following the 2011 civil war that toppled longtime dictator Moammar Gadhafi. Fighters from Libya also have come into Egypt from these borders, security officials say.

Egypt has vowed to tighten security along its borders.

This is the second brazen attack on troops in recent years during the holy month of Ramadan, when observant Muslims fast from dawn to sundown. In 2012, gunmen attacked a checkpoint near Egypt’s border with Gaza and Israel, killing 16 soldiers. It was one of the highest number of troops killed in recent years in one attack.

The attack was one of the biggest assaults since Islamist president Mohamed Morsi’s ouster.

Militants have stepped up attacks on the security forces since Morsi was toppled in July 2013 as the army struggles to quell an Islamist insurgency that has killed scores of soldiers and police, mainly in the Sinai Peninsula bordering Israel and the Palestinian Gaza Strip.

The attack came amid repeated warnings by Egyptian officials of a possible spillover of violence from across the border with Libya where relentless bloodshed over the past few months has sparked fears of all-out civil war.

It also comes just days after seven civilians and a soldier were killed when three rockets slammed into the restive Sinai.

Most of the attacks that have surged since Morsi’s ouster have been claimed by jihadists fighting against the bloody crackdown by the authorities on Morsi’s supporters.

Many of these attacks have rocked not just the Sinai but also the mainland, and have included bombings and assassinations of top police officers.

Since the army removed Morsi, a police crackdown on his supporters has left more than 1,400 people dead in street clashes, upwards of 15,000 jailed and some 200 sentenced to death.

Morsi himself and several senior leaders of his Muslim Brotherhood movement are also on trial.

Egypt is also currently embroiled in mediating ceasefire negotiations between Israel and Hamas, who have been engaged in an escalating conflict for the last 12 days, although there is no evidence of any connection between the negotiations and the attack Saturday.

Egypt has taken a notably tough stance against the demands of Hamas, which is an offshoot of Morsi’s Muslim Brotherhood. And as part of the Egyptian military’s battle against Islamists in the Sinai, it has effectively closed the Rafah border crossing between Egypt and Gaza and destroyed many of the smuggling tunnels Hamas once used to bring goods into the coastal enclave, essentially cutting it off from the outside world and virtually bankrupting Hamas.

Egypt has also accused Hamas of supporting Islamists in the Sinai and even harboring them in the Gaza Strip.

Earlier Saturday, Egyptian soldiers prevented a aid convoy of 500 activists from reaching the Rafah border crossing and entering Gaza.