The heavily armed attackers had captured a border post at Rafah, commandeered cars and tried to smash their way over the border, Israel said.
One vehicle apparently blew up at the Kerem Shalom crossing, while the other was destroyed by the Israeli air force.
Islamist militants have been blamed by both sides for carrying out the attack.
The attack on the border post close to Gaza and Israel took place at around sunset at eight o'clock, just as the guards had stopped work for the traditional iftar meal, which breaks the daily fast during the Islamic holy month of Ramadan.
Masked gunmen dressed as Bedouin nomads opened fire on police with guns and rocket-propelled grenades, Egyptian state television said.
Sixteen soldiers and border guards were killed and another seven were wounded, officials said.
In all, eight militants were killed, Israel's Defence Minister Ehud Barak told a parliamentary committee in Jerusalem.
The vehicle that blew up was loaded with explosives, the Israeli prime minister's spokesman, Ofir Gendelman, said on Twitter.