The day before the midterm elections in 2010, Joe Biden traveled to Vermont to headline a rally for the Democratic candidate for governor. On the stage, he gave a shout out to the state's two senators. Bernie Sanders, he said, "is the conscience of the United States Senate."

"I love this guy. You should be happy with this guy," Biden said to cheers. He recalled a conversation with Ted Kauffman, his former chief of staff who had taken his seat in the Senate when Biden became vice president. "I said to him, 'OK, Ted, you've been there two years, of all the people you work with who do you like best?' And he said, 'Bernie Sanders. Bernie, that's a high quality.' This guy knows talent, man."

Nearly a decade later, Biden and Sanders are top rivals leading the pack for their party's nomination for president — a contest in which the Vermont senator's once-fringe policy views are now considered "the conscience" of the field.

Get Breaking News Delivered to Your Inbox

The two men are roughly the same age — Biden is 76, Sanders 77 — and have long careers in public service. They're both pitching themselves as advocates for the working class who can win back voters who migrated to President Trump in 2016. At the same time, they differ starkly on foreign and domestic policy, as well as style: Biden the gregarious institutionalist and Sanders the unabashed gadfly.

Early polls showing them atop the most crowded and diverse Democratic field in modern campaign history have put a spotlight on their competing visions for victory. And this week, Sanders fired his first official shot across the bow.

"I think when people take a look at my record versus Vice President Biden's record, I helped lead the fight against NAFTA. He voted for NAFTA," Sanders said on CNN. "I helped lead the fight against [permanent normal trade relations] with China. He voted for it. I strongly opposed the Trans-Pacific Partnership. He supported it. I voted against the war in Iraq. He voted for it."

Sanders and Biden have a cordial relationship and respect one another, but are not particularly close, according to aides. They overlapped for two years in the Senate, but served on different committees, and didn't work on much together. Biden focused on foreign policy in the upper chamber, while Sanders mostly worked on economic issues.

"They weren't close buddies in the Senate," says Michael Briggs, Sanders' former spokesman. "But they got along well ... Biden was very nice to him during the campaign."

In 2015, while still mulling a run for president, Biden reportedly told donors at a Democratic Senatorial Campaign Committee fundraiser, "I am not a populist. But Bernie Sanders, he's doing a helluva job." Then, shortly after he decided not to run, Biden invited Sanders to the Naval Observatory to talk about a variety of campaign issues.

"I've known Joe for many years and I like Joe. Joe is a friend of mine," Sanders said in an interview with CBS News' Ed O'Keefe in April, before Biden entered the race. "I look forward to having a good issue-oriented debate with him and with other candidates. And one thing I'm quite confident about is that among the Democratic candidates, there is an understanding we shouldn't be attacking each other on personal levels."

Sanders allies say the senator isn't likely to escalate the rivalry beyond policy contrasts. But Biden could provide a nice foil for Sanders campaign.

"To the extent it allows him to talk about these issues that animated his campaign like none other that I've watched, it helps," says Briggs.

Aside from supporting a $15 minimum wage, Biden has so far stayed away from Sanders-inspired proposals. While campaigning in Pittsburgh earlier this week, Biden advocated for a public option to buy government insurance, not Sanders' "Medicare for All" plan that has been backed by many of the candidates.

In Pittsburgh, Biden invoked themes of economic inequality. "The country wasn't built by Wall Street bankers, CEOs and hedge fund managers," he said. "It was built by the great American middle class."

But in a speech at the Brookings Institution in 2018, Biden drew a contrast with Sanders. "I love Bernie, but I'm not Bernie Sanders. I don't think 500 billionaires are the reason why we're in trouble," he said. "I get in trouble with my party when I say wealthy Americans are just as patriotic as poor folks."

In many ways, Sanders' increasing influence among Democrats raises a set of challenges for Biden in navigating a party that has shifted to the left since he last ran for office. But in other ways, Bernie's candidacy could help Biden stand out amid a field that Mr. Trump broadly paints as socialists. Biden seems to have identified the latter dynamic, and is already running something of a general election-style campaign against the president.

Yet Biden and Sanders are competing for similar voters, particularly those in the Midwest and Rust Belt. And allies from both camps say the two have a valuable authenticity factor that will resonate. Early polls show some overlap. A Morning Consult poll found that Biden and Sanders supporters named the other as their second choice. And a Des Moines Register/CNN survey of Iowa voters found similar results.

"They are both appealing to Trump country where there was loss of work to trade and closing factories," says a former Sanders aide. "I think people will like the statesman way of Biden. But in some ways they are looking for a fight, someone who is going to brawl with [Trump]. Bernie ... is more likely to call out businesses by name and take them to task."

Beyond their overlapping constituencies, Biden is likely to appeal more to older voters, while Sanders is likely to do well among younger voters.

Both, however, have made clear that even as their rivalry kicks into high gear, Mr. Trump remains the mutual target. On Thursday, Sanders tweeted one area of support on which the two agree:

"I thank my friend @JoeBiden for joining our effort to end U.S. involvement in the Saudi military campaign in Yemen, which, over four years of war, has experienced the world's worst humanitarian crisis. We must override @realDonaldTrump's veto."