Dominic Cardy has spent years trying to rebuild New Brunswick's New Democratic Party and see it return to the legislature.

But that time in the political backrooms and on the campaign trail came to an end Monday with Cardy still on the outside of the legislature looking in.

Cardy, 44, failed in his bid to win the riding of Fredericton West–Hanwell and the party failed to capture a seat in the legislature.

Cardy announced his resignation as party leader during his concession speech. The resignation will become effective at the party's convention in the fall.

Cardy told supporters he knew when he took on the leader's post in 2011 that the journey would end in one of two ways — with a breakthrough, or with a disheartening loss.

Cardy handshake

NDP Leader Dominic Cardy reached out to shake Liberal Leader Brian Gallant's hand over a candidate's decision to link to a parody video that compared the Liberals to Nazis. Gallant refused the offer. (CTV debate)

"My mesasge to my party, that I love, and my province, which I love, is that it is much better to reach your arms out wide and to fall and to stand up again than it is never to dream at all," Cardy told supporters.

"Tonight, we start dreaming for next time, organizing for next time, because in the end, New Brunswick does deserve better and that message is going to resonate throughout the weeks and months and years to come."

Cardy then told supporters he will resign as party leader at the party's convention later in the fall, leaving the NDP to seek their fourth party leaders since 2005.

"Ultimately this is not about one person, and we had the chance in this election," he said. "We could either have focused on my single seat, or we could have tried to go out there, open our arms wide and say, `We have a vision for a better New Brunswick, a better government,' and that to me is what this is all about.

"And someone new will lead that party and they will take us there."

Incumbent Progressive Conservative Brian MacDonald held on to Fredericton West-Hanwell with about 36 per cent of the vote. Cardy finished second with about 30 per cent.

Cardy and the New Democrats were hoping for a breakthrough and a return to the legislature in the 2014 election. The party registered 17 per cent support in a Corporate Research Associates poll released Sept. 2. But in a subsequent poll released in the campaign's final days, NDP support had fallen to 11 per cent.

Cardy was widely seen as the strongest performer in the CBC leaders' debate on Sept. 9. And in the campaign's final weeks, Cardy and the NDP found themselves in the centre of several stories on the campaign trial.

The last week saw an NDP staffer crash a campaign stop by Liberal Leader Brian Gallant. In another incident, the Liberals were outraged when an NDP candidate tweeted a video parody depicting Gallant and Liberal party members as Hitler and Nazis. Also, NDP candidate Paul Musgrave in Kent South publicly questioned Cardy's shale gas stance.

Cardy took over as the leader of the NDP in 2011, when he was acclaimed to the position. He inherited a party with no seats and set out to rebuild, with an eye to returning the party to the legislature.

The NDP hasn't had an MLA on the floor of the Legislative Assembly since Elizabeth Weir resigned in 2005 to accept a government appointment from Bernard Lord's Progressive Conservative government as the head of Efficiency New Brunswick.

When Margaret-Ann Blaney replaced Weir at Efficiency NB in 2012, that created a byelection in the riding of Rothesay. Cardy ran in that election, finishing third in a race won by Conservative Ted Flemming.

Cardy is a moderate politically and an admirer of former British prime minister Tony Blair. Since taking over as leader, Cardy has moved the provincial NDP more toward centre on the political spectrum, resulting in criticism from traditional supporters, some of whom moved to the Green Party, including former leader Allison Brewer, who led the party in the 2006 election.