Imran Ali, 24, was on trial for the killing of a six-year-old girl in the eastern city of Kasur last month. Her death brought rampaging mobs onto the streets in search of her killer.
Imran Ali was handed capital punishment for kidnapping, rape, murder and an act of terrorism while a life sentence was also given to him for sodomy. He is also suspected of killing other girls.
Residents of the area have said the murder was the 12th such incident in a year.
The girl's family registered a complaint with the local police after she went missing on January 4.
On Monday, the anti-terrorism court had indicted Ali and started regular proceedings after he refused to accept the charges levelled against him by the police.
He confessed after police investigators said they had matched DNA from nine victims, including Zainab, with Ali.
State prosecutor Ehtesham Qadir said Imran Ali, who had pleaded guilty during the five-day trial, was in the courtroom for the verdict. The police finally nabbed the predator on January 23, 2018.
The prosecutors said he also received life imprisonment and fines totalling 3.2 million rupees ($30,000) for additional charges of hiding his victim's body.
At least two people died and dozens more were injured in Kasur when protests turned violent. Zainab was kidnapped from near her aunt's house in Kasur on January 4. His lawyer had withdrawn from the case after Imran confessed.
Television stations repeatedly broadcast chilling CCTV footage purportedly showing the young girl walking hand-in-hand with an unidentified male in what may have been her last moments.
There have been complaints of a number of missing children in Kasur district since 2015, when authorities uncovered a paedophile ring linked to a prominent local family.
Pakistan recorded at least 17,862 cases of sexual abuse to minors between 2013 and 2017, 10,620 of m against girls and remaining 7,242 against males, according to a report by Ministry of Human Rights elaborated with NGO Sahil.