By John Whitesides

PORTSMOUTH, N.H. (Reuters) - Democrat Bernie Sanders endorsed former rival Hillary Clinton for president in a belated show of party unity on Tuesday, saying it was critical that Democrats come together to defeat Republican Donald Trump in the Nov. 8 election.

"She will be the Democratic nominee for president, and I intend to do everything I can to make certain she will be the next president of the United States," Sanders told a raucous crowd that included plenty of vocal Sanders supporters.

Five weeks after Clinton clinched the Democratic presidential nomination, the U.S. senator from Vermont ended his upstart campaign and joined her at a rally in Portsmouth, New Hampshire, to put their bitter primary battle behind them.

"I have come here to make it as clear as possible as to why I am endorsing Hillary Clinton and why she must become our next president," Sanders said.

Sanders' endorsement brought the most prominent holdout in the party's liberal wing into Clinton's camp less than two weeks before the opening of the Democratic National Convention in Philadelphia, where Clinton is expected to become the party's nominee.

Clinton hopes the joint appearance will help her win over Sanders supporters, some of whom carried Sanders signs into the rally and frequently drowned out her supporters. In recent Reuters/Ipsos polling, only about 40 percent of Sanders backers said they would back Clinton, and the crowd at Tuesday's rally made it clear she still had work to do.

"I am absolutely certain I will not vote for Hillary Clinton," said Gale Bailey, a Sanders supporter and an unemployed graphic designer from Rochester, New Hampshire, who attended the rally in a Sanders T-shirt.

"She's a crook, and I'm not going to vote for a crook," Bailey said, adding that she would write in Sanders' name on the November ballot.

The appearance in Portsmouth concluded weeks of negotiations between the two camps as Sanders pressed for concessions from Clinton on his liberal policy agenda.

It came after Clinton last week adopted elements of Sanders' plans for free in-state college tuition and expanded affordable healthcare coverage. Sanders also successfully pushed to include an array of liberal policy positions in the Democratic platform, which a committee approved on Saturday.

Sanders did not win all of his policy fights, most notably failing to win support for blocking a vote in Congress on the Trans-Pacific Partnership trade deal.

But he told reporters at the rally in Portsmouth that "our job now is to see that platform implemented by a Democratic Senate, a Democratic House and a Hillary Clinton president, and I am going to do everything I can to make that happen."

Top Democrats, including President Barack Obama and Senator Elizabeth Warren of Massachusetts, a favorite of the party's liberal wing, have already announced their support for Clinton, leaving Sanders at risk of being left behind in the Democratic battle against Trump.

"I think all signs point to the fact that we're going to have a very united party going into Philadelphia," Clinton campaign spokesman Brian Fallon said on CNN earlier on Tuesday, "and when you compare it to the Republicans, we're going to be miles ahead of them."

Trump has struggled to unify the Republican Party after alienating many establishment figures with his stances on immigration, Muslims and women. A number of prominent Republicans are skipping the party's convention in Cleveland next week.

In another sign of the Democrats' growing unity, two prominent liberal groups that had backed Sanders, the Communications Workers of America labor union and the Congressional Progressive Caucus PAC, announced their support for Clinton on Monday.

The congressional group is led by two of Sanders' biggest backers in Congress: Raul Grijalva of Arizona, who already had endorsed Clinton, and Keith Ellison of Minnesota.

New Hampshire is where Sanders first served notice of the strength of his campaign by beating Clinton handily in the primary.

In 2008, Clinton and Obama held their first joint rally in the state after his victory in that brutal primary race. To make sure everyone got the point, it took place in the town of Unity.

(Editing by Leslie Adler and Lisa Von Ahn)

More From Missoula Current