The clashes lasted all day near Tanjung Priok, the city's northern international port, with police trucks being flipped and torched, and blood being left on the streets.
Police denied that the tomb of Habib Hasan bin Muhammad Al Hadad, a revered 18th century Arab cleric, would be removed. They said that they only want to remove illegal squatters from the cemetery.
"Two people died ... the number may rise," Zainuri Lubis, the national police spokesman, said.
Cucu Ahmad Kurnia, the city spokesman, earlier said: "Seven people have been critically injured ... one [security officer] had his hand cut off and another had his stomach ripped out with a machete.'
Kurnia said that most of the wounded suffered head injuries from being pelted with rocks.
The majority of the injured were security forces. About 2,000 security personnel and 600 police were brought in to control the demonstrations.
The unrest in the city's main seaport was the worst in Jakarta for several years.
Kurnia described the events as "anarchic" and promised to negotiate with local residents about changes to the cemetery.
"They've misunderstood ... we're not removing the tomb but only the old buildings and gate," he said.
"We've stopped the demolition and will resume negotiations with demonstrators another time."
The protesters said that the government was trying to remove the tomb of Al Hadad, also known as Mbah Priok.
Al Hadad is said to have helped spread Islam in North Jakarta and some people believe the tomb grants wishes to those praying there.
Indonesia is the nation with the highest Muslim population in the world.