British Columbia has its first minority government in 65 years as the Liberals squeaked out a razor-thin victory over the NDP on Tuesday, with the Green party holding the balance of power for the first time in Canadian history.

Christy Clark's Liberals won 43 seats, the NDP under John Horgan got 41 and the Greens led by Andrew Weaver achieved a major breakthrough by picking up three seats.

The NDP won one riding by only nine votes, making a recount a certainty that will determine the difference between a minority and an ultra-thin majority if it were to flip to the Liberals.

Clark said she intends to lead the next government, adding the result presents an opportunity to open up a new dialogue "about how we do things, what we should do, how we want to shape the future of our province."

"Tonight is the beginning of something very different, and something that I think could be really exciting for the future of our province and our kids," she said.

She said her party won the popular vote, finishing with 40.9 per cent compared with the NDP's 39.9 per cent based on preliminary election results. Clark said she is confident that when absentee ballots are counted, they will strengthen the Liberals' margin of victory.

As the incumbent premier and with the most seats, Clark would be expected to get the first opportunity to form a minority government with the support of the Greens, who finished one seat short of gaining official party status in the legislature.

Not ready to concede defeat

Horgan was not ready to concede defeat, however, saying that British Columbians have waited 16 years for a new government and will have to wait a bit longer until all the votes are counted.

"This is what we do know: a majority of British Columbians voted for a new government and I believe that's what they deserve," he said.

The campaign began four weeks ago with Clark and the Horgan locked in a tight race to be premier, and Weaver hoping to build upon his one seat in the legislature.

Weaver, whose party doubled its popular vote to 16.7 per cent compared with the last election, looked ecstatic as he addressed supporters in Victoria.

"What a historic day for British Columbia," he said. "People across British Columbia have shown that they are ready for politics to be done differently."

Weaver wasn't ready to tip his hand on whether he would support the Liberals or NDP in a minority government.

"In the days ahead there will be plenty of discussions taking place between all parties. Now is not the time for those discussions, now is the time for Greens across North America to celebrate," he told a cheering crowd.

After his speech, Weaver said he called Clark and Horgan to congratulate them on their campaigns and "start the conversation on the next steps for our province in the days ahead."

Andrew Wilkinson, advanced education minister in Clark's government, said definitive results might not be available until the end of the month when absentee ballots and judicial recounts must be completed.

"It could be some time before this is completely clear."

Cabinet ministers lose seats

Based on preliminary numbers, voter turnout was up slightly to 56.45 per cent on Tuesday compared with 55.32 per cent in 2013.

The NDP won one riding by only nine votes, making a recount a certainty that will determine the difference between a minority and an ultra-thin majority if it were to flip to the Liberals.

All party leaders were re-elected in their ridings. New Democrat Leader John Horgan won his seat in Langford-Juan de Fuca, while Liberal Leader Christy Clark won in Kelowna West. Green Leader Andrew Weaver regained his seat in the Victoria riding of Oak Bay-Gordon Head.

Weaver's party has at least doubled its representation in the legislature, adding Adam Olsen in North Saanich and the Islands, just north of Victoria, who beat the NDP incumbent. Green candidate Sonia Furstenau is leading in Cowichan Valley, also on Vancouver Island.

Well-known First Nations leader Ellis Ross took the northwestern riding of Skeena for the BC Liberals from an NDP incumbent, an upset for the star candidate and chief councilor of the Haisla Nation.

Attorney General Suzanne Anton lost her Vancouver riding in one of the first upsets of the night for the Liberals as election results were still rolling in.

NDP candidate Jagrup Brar defeated Liberal cabinet minister Peter Fassbender in Surrey-Fleetwood, a fast-growing suburb in the Lower Mainland.

The NDP came on strong in Metro Vancouver ridings with the Liberals holding onto their strongholds the rest of the province.

The Liberals were trying to win a fifth successive majority government after holding power for 16 years.

Clark campaigned on jobs, megaprojects

Clark's strategy marked a return to the Liberals' winning approach in 2013, when she promoted her party as the only one that could create and protect jobs while portraying the NDP as disastrous managers of the economy.

While her promise of a booming liquefied natural gas industry has not materialized, Clark was able to point to B.C.'s strong economy as proof of the Liberals' financial savvy. The province has Canada's lowest unemployment rate and has led the country in economic growth two years in a row.

Horgan sought to portray Clark as out of touch with regular British Columbians who feel the economy is not working for them, while Weaver cast the Greens as political outsiders.

The New Democrats' platform contained big-ticket promises including $10-a-day childcare, freezing hydro rates for a year and eliminating tolls on two major Lower Mainland bridges. Horgan said the NDP would balance the budget by raising taxes on the top two per cent of earners and by using a $500-million "LNG prosperity fund" that Clark created out of general revenue.

But the Liberals sowed doubts about the NDP's ability to pay for its promises, repeatedly accusing the party of a massive "crater" in its platform that could only be filled with new taxes.

Weaver reminded voters that his party was the only one to ban corporate and union donations and his promises included electoral reform, increasing the carbon tax and investing millions in clean technology jobs.

Weaver, a climate scientist who became the first Green elected to the B.C. legislature four years ago, said if the party only won one seat this time he would not run again.

B.C.'s campaign finance laws dominated headlines before the election began. The province allows unlimited corporate and union donations and the RCMP is investigating fundraising by the province's political parties.

After months of pressure, the Liberals committed to convening a panel to review political fundraising. The NDP and Greens have promised an outright ban on corporate and union donations.

The campaign was thrown a curveball when U.S. President Donald Trump announced a 20-per-cent tariff on softwood lumber in late April. More than half of B.C. softwood lumber exports go to the U.S.

Clark called for a retaliatory ban or tax on U.S. thermal coal exports moving through B.C. ports.

Horgan blamed Clark for the softwood tariff, saying that if she had managed the file better the duties could have been avoided.

— With files from Dirk Meissner in Victoria