Written by Lord Macaulay, the Indian Penal Code 1860, as it was named at the time, made same-sex sexual acts illegal under the British law of 'Unnatural Offences', known as carnal knowledge.
After Pakistan received independence in 1947, the Parliament decided to continue using the same Penal Code, merely changing the title to Pakistan Penal Code (Act XLV of 1860).