The unidentified men opened fire on a police car carrying an officer and four agents on the coastal highway between second city Alexandria and Marsa Matruh, close to the Libyan border.
The policemen returned fire and during the exchange their car overturned and caught fire with all five of them on board, the security officials said.
The bodies of the policemen were charred, the officials said.
Two gunmen were also killed in the clash while the rest of them were able to flee, the officials said, describing the assailants as "terrorists".
