OTTAWA — The Conservatives have held onto the late Jim Flaherty’s suburban Toronto seat — but their grip on the riding has been significantly loosened.

Tory candidate Pat Perkins has eked out a byelection victory in Whitby-Oshawa, fending off a surprisingly strong challenge from Liberal Celina Caesar-Chavannes.

With two-thirds of the polls reporting, Perkins, a high-profile, former two-term Whitby mayor, has taken 48% of the vote — just six points ahead of political newcomer Caesar-Chavannes.

Former finance minister Flaherty, who died suddenly last spring, took the riding with a comfortable 58% in 2011, more than 30 points ahead of his nearest rival.

Support for New Democrat Trish McAuliffe, who came a respectable second to Flaherty in 2011 with 22% of the vote, has collapsed to less than 8%.

The close result, despite an all-out push by the Conservatives, suggests the resurgent Liberals may give the ruling party a run for its money in the crucial suburban ridings around Toronto — a key battleground in next year’s general election.

In Yellowhead, Tory candidate Jim Eglinski, a former RCMP officer and former mayor of Fort St. John, has captured 64% of the vote, a commanding lead with just over half of the polls reporting.

That’s well ahead of Liberal Ryan Mahugn at 18% and New Democrat Eric Rosendahl at just under 10%.

Still, the Conservative margin of victory is shaping up to be narrower than 2011 when Rob Merrifield won the riding with a whopping 77% of the vote.

The Liberal share of the vote has more than quintupled over the dismal 3% the party won in 2011, when it finished fourth behind the NDP and Greens.

The NDP is down slightly from its 13% share in 2011; the Greens are not running a candidate in the byelection.