WHITBY, Ont. -- The Progressive Conservatives won a byelection Thursday in Whitby-Oshawa, easily fending off the Liberals despite the governing party dropping Prime Minister Justin Trudeau into the campaign in the waning days.

The Tories have held the riding east of Toronto since 1995, but the Liberals had hoped the resignation of Christine Elliott would afford them a crack at the seat.

Progressive Conservative Lorne Coe garnered about 50 per cent of the vote.

The byelection was triggered when Elliott resigned the seat in the summer, ending a mini-family dynasty. Her husband, the late Jim Flaherty, represented the area provincially from 1995 to 2006, when he jumped to federal politics.

Elliott took up the banner, holding the seat until she stepped down in late August, months after she lost the party's leadership race.

The Liberals had so strongly hoped they could win the riding -- even though the result won't change the balance of power at the legislature -- they had Trudeau and his "sunny ways" refrain sweep into town Tuesday night for a rally for Liberal candidate Elizabeth Roy.

Progressive Conservative Leader Patrick Brown couldn't resist a dig at the prime minister as he introduced his new caucus member.

"It's nice to see that 'sunny ways' have come with blue skies here in Whitby-Oshawa," he said.

Trudeau's participation came after Premier Kathleen Wynne took a high-profile role in his successful federal campaign, though it's unusual for a prime minister to wade into a provincial byelection.

Brown praised the Flaherty-Elliott legacy in the riding and said he couldn't think of anyone better than Coe to fill those "huge shoes."

The Liberal and NDP candidates in the byelection had said they were encountering a lot of voters who had supported Elliott and were disappointed she didn't win the leadership.

But Coe had Elliott's backing, even though as the province's new patient ombudsman, a politically neutral position, she couldn't actively campaign for him.

Brown predicted that if the trend of Coe's victory, and his own byelection win last year, continues, 2018 will see a Progressive Conservative majority government. Both ridings, however, were considered solid Tory seats.

Wynne, too, looked ahead to 2018.

"As I was coming in, people were saying, 'In two years. In two years we can do this.' So there's another shot at this," she said.

"The plan that we are implementing is going to benefit every person in this riding and people will see that."

Roy finished second, while New Democrat Niki Lundquist finished third, according to preliminary results.