Mr Sharif's daughter Maryam said her mother Kulsoom won despite Pakistan Muslim League-Nawaz (PML-N) party workers being threatened and kidnapped. Although she did not name anyone, PML-N sources said she was referring to alleged intimidation by parts of Pakistan's powerful military.
The military could not be reached for comment.
"This is not an ordinary victory," Maryam said in a speech to jubilant PML-N supporters. "You have defeated not only people who were in the field but also those who are invisible."
The main opposition Pakistan Tehreek-e-Insaf (PTI) party made gains but alleged voter irregularities in the eastern city of Lahore, the electoral heartlands of the Sharif family since 1980s.
Official results are yet to be announced but party officials who also tallied the numbers say Kulsoom, who did not campaign as she is receiving treatment for cancer in London, scooped about 53.5 percent of the vote, with the party's majority reduced from about 61 percent in the 2013 general election.
The PML-N wanted to demonstrate that support for the Sharif family was undiminished despite the Supreme Court's removal of Nawaz, who has kept control of the party and installed long-term ally Shahid Khaqan Abbasi as prime minister.
Maryam said dozens of PML-N activists were blindfolded and picked up from their homes at night, while others received threatening phone calls from unknown numbers during the campaign.
"This victory is a message to the forces hatching conspiracies against Nawaz Sharif that there would be only rules of people and democracy," added Maryam.
Maryam, who some PML-N leaders see as a future leader, spearheaded the PML-N campaign for her mother with fiery speeches denouncing the judiciary. In an interview with Reuters before the vote, she hinted at military involvement in her father's ouster.
Nawaz, who served two stints in power in 1990s until he was deposed in a military coup in 1999, had strained ties with the military during his third stint in power that ended in his ouster, when the Supreme Court disqualified him for failure to declare a monthly salary, equivalent to around $2,700, from a company owned by his son. Sharif denies receiving the salary.
Opposition leader Imran Khan - whose threats of street protests pushed the Supreme Court to launch a probe into Nawaz's wealth - had sought to build on the success of his anti-graft crusade by making inroads into Sharifs' power base in Punjab.
Khan turned the by-election into a plebiscite about corruption and has accused the provincial Punjab government, which is run by Nawaz's brother Shahbaz, of abusing state resources to help the PML-N campaign.
PTI candidate Yasmin Rashid, a local gynaecologist, saw her share of the vote rise from about 35 percent to 41 percent but she afterwards said about 29,000 voters did not have fingerprint identification with the national database.
PML-N's lead was reduced in part by the strong showing of Yaqoob Sheikh, who the United States in 2012 designated a terrorist.
Sheikh received 4,174 votes, or nearly 4 percent of the total vote after being backed by a new Milli Muslim League party led by an Islamist firebrand who is the subject of a $10 million bounty offered by the United States.
Hafiz Saeed heads the Jammat-ud-Dawa (JuD) charity, having founded and formerly led the Lashkhar-e-Taiba (LeT) militant group that carried out the 2008 attacks on the Indian city of Mumbai that killed 166 people. The United States has placed Saeed, the charity and LeT on its terrorist list.
The United States, in 2012, said Sheikh was a senior LeT leader.
(Except for the headline, this story has not been edited by NDTV staff and is published from a syndicated feed.)