“I’m not afraid of death,” said Ed Koch, the former New York mayor who died Friday at the age of 88. “I believe in God. I believe in the afterlife. I believe in reward and punishment . . . and I expect to be rewarded.

“But you have to be prepared.”

He was. As revealed in “Koch,” the documentary opening Friday in New York, the savvy politician did not want to leave the writing of his epitaph to anyone else. So he took care of it himself in advance.

In the film, Koch visits his own grave with Diane Mulcahy Coffey, his chief of staff. On the way to Manhattan’s Trinity Church Cemetery, the proudly Jewish mayor explains why he chose the Protestant burial ground as his final resting place.

With help from rabbis, he had visited old Jewish cemeteries in Manhattan, but they weren’t to his liking (and Koch had no intention of ever leaving Manhattan — even in death).

“They’re all locked up, and no one goes there,” he says in the film. “I want to be in a bustling cemetery.”

At the gravesite, Koch reads aloud the engraved words he himself composed. But viewers also see that he has included a famous quotation by 38-year-old journalist Daniel Pearl, the Wall Street Journal reporter who was kidnapped and beheaded by Islamic terrorists in 2002. Just before he was murdered, Pearl declared, “My father is Jewish, my mother is Jewish, I am Jewish.”

An admirer of those words, Koch had more in common with Pearl than he could have predicted. In the end, both men died on Friday, Feb. 1 — the same day, 11 years apart.