ISLAMABAD, Pakistan — When a friend told Hussain Liaquat that police officers in the Pakistani capital might be checking cars for anything red or heart-shaped the night before Valentine’s Day, he decided to get creative.

Mr. Liaquat, 22, went to the giant Saeed Book Bank in Islamabad and found a poster from “House of Cards,” his girlfriend’s favorite television show. Then he went in search of the perfect romance novel.

“I decided not to buy her balloons and chocolates, to avoid police confiscating them,” the mathematics student said, leafing through a copy of Erich Segal’s “Love Story.”

“Someone told me this is like the ‘Romeo and Juliet’ of the 20th century,” he said. “I think I’ll get it.”