Liberal Leader Stephen McNeil and his team have done what no Nova Scotia government has been able to do since 1988: win back-to-back majorities.

The feat didn't come easily, however. The party was below the 26-seat threshold for much of the night, with several prominent candidates staring at defeat until last-minute rescues as final poll results came in around midnight. Several high-profile cabinet ministers were unseated.

It's a slender majority that CBC News is projecting, but it means the Liberal budget introduced last month will certainly be passed, and McNeil will continue with the agenda he's laid out over the last 30 days. That plan calls for continued fiscal prudence while increasing investments in health care, infrastructure and education.

'I've heard you and I've listened'

Unlike 2013, when the Liberals cruised to an early and easy victory with 33 seats, it wasn't until close to 1 a.m. when their majority was declared. The party was elected in 27 seats, the Tories were elected in 17 seats and the NDP was elected in seven seats.

In the last general election, the Liberals won 33 seats, the Tories won 11 and the NDP won seven.

In what was possibly a nod to criticism over health care, as well as the Liberals' contentious relationship with unions, McNeil was conciliatory.

"I want to assure you that I've heard you and I've listened," he said of health care.

"And we have a plan, as well as the opposition parties have a plan and we can work together to make it better."

John Buchanan and his Tory team was the last government to achieve back-to-back majorities.

Seat movement benefits Tories

While the Liberals, Tories and NDP all held some expected districts, it was the PCs who, early on, flipped seats, including taking Cumberland North from the Liberals and Queens-Shelburne from the NDP. They also knocked off Liberal incumbent Pam Eyking in Victoria-The Lakes and took Sackville-Beaver Bank from the Liberals on the strength of former Halifax municipal councillor Brad Johns.

The biggest gain of all for the Tories was Cape Breton-Richmond, where Alana Paon needed the final poll of the night to knock off longtime Liberal veteran and cabinet minister Michel Samson.

NS ELXN 20170530

Nova Scotia Premier Stephen McNeil voted at a community centre in Granville Centre, N.S., on Tuesday. (Andrew Vaughan/The Canadian Press)

McNeil held his seat in Annapolis, as did Tory Leader Jamie Baillie in Cumberland South. NDP Leader Gary Burrill also won his seat in Halifax Chebucto, ensuring he will have a seat in Province House.

McNeil told supporters at the Bridgetown Curling Club that people were watching "democracy at its best."

"We've seen tonight why every vote counts," he said.

"It was a hard-fought campaign and I've lost some colleagues tonight. I am grateful for their service and their friendship."

Jamie Baillie

Jamie Baillie made a commitment early Wednesday morning to continue to lead the Progressive Conservative Party. (CBC)

Baillie told supporters gathered in Springhill that he was proud of his team and their performance on a night when they had the most seat pickups and largest vote-share increase.

"Look at how far we've come, look at the gap we closed, look at what you have done."

He also put to rest any questions about his future as party leader.

"I will continue to lead this party into the future."

Baillie said he believes the shift in seat count and vote share is proof people were empowering his party.

"I deeply believe that the people of Nova Scotia have spoken tonight. They have said that they're not happy with the leadership of Mr. McNeil. They are not happy with the way the Liberals have governed the province."

gary burrill

NDP Leader Gary Burrill said the cause of social, environmental and economic justice had been strengthened. (CBC)

A victorious Burrill told a jubilant crowd gathered at a downtown Halifax hotel that the cause of social, environmental and economic justice has been strengthened in Province House.

It was time to "celebrate the fact that in the course of 30 days of this election we have been able to do nothing less than change the nature of the conversation in politics in Nova Scotia," said Burrill.

The win validates the party's call to ensure everyone has enough to eat without needing a food bank, health care is there for everyone who needs it, students aren't weighted down by debt and people all have jobs that pay them enough to live, he said.

"Our commitment to this great purpose has been deepened and strengthened and made more real by this campaign."

Highlights from the live coverage of Nova Scotia Votes 2017 on CBC News1:40

For the NDP, Burrill's win wasn't the only high point.

The party's incumbents Dave Wilson (Sackville-Cobequid), Lenore Zann (Truro-Bible Hill-Millbrook-Salmon River) and Lisa Roberts (Halifax Needham) were all re-elected. The NDP also wrestled back Cape Breton Centre from the Liberals, which they lost in a 2015 byelection, thanks to Tammy Martin topping Liberal David Wilton.

If the party had another win on Tuesday that rivaled the size of Burrill's, it was newcomer Sue Leblanc who knocked off Community Services Minister Joanne Bernard in Dartmouth North.