WASHINGTON — With little affection or trust between them, Hillary Clinton and Senator Bernie Sanders met privately for nearly two hours on Tuesday night to size each other up as they started exploring what kind of alliance they might build for the general election battle against Donald J. Trump.

Yet Mr. Sanders chose to withhold his endorsement of Mrs. Clinton, several Sanders advisers said, because he wants her to take steps to win his confidence before the Democratic convention, where his supporters expect him to speak and Clinton advisers hope he will give her his full-throated backing.

Aides to Mrs. Clinton said she had never expected his endorsement Tuesday night. A statement from the Clinton campaign after the meeting described it as “a positive discussion about their primary campaign, about unifying the party and about the dangerous threat that Donald Trump poses to our nation.” They discussed issues like raising wages and reducing college costs, and “agreed to continue working on their shared agenda, including through the platform development process for the upcoming Democratic National Convention.”