Both Democratic candidates Hillary Clinton and Bernie Sanders spoke passionately about the desire to stop deporting immigrants who entered the country illegally and to provide a path to citizenship at The Washington Post/Univision debate in Miami. (Sarah Parnass/The Washington Post)

Let's get one thing out of the way: Sen. Bernie Sanders (I-Vt.) is no conservative when it comes to immigration, as Hillary Clinton suggested in Wednesday's Democratic debate.

Since coming to the Senate in 2007, Sanders has consistently voted for comprehensive immigration reform and a path to citizenship. But Clinton is right that, in Sanders's first year in the Senate, Congress had the best opportunity it has had in years to pass immigration reform. Clinton voted for the bill, and Sanders voted against it.

To the dismay of many immigration advocates, many Democrats and President George W. Bush, the bill ultimately failed.

On Wednesday, Clinton repeatedly tried to group Sanders in with hard-line Republicans who also voted to kill it.

"You made it clear by your votes, senator, that you were going to stand with Republicans," she said.

Sanders said that Clinton was twisting his vote into something it wasn't. And he's kind of right. Just like the two candidates' back and forth Sunday on whether Sanders supported the auto bailout, there is much more nuance to a senator's vote than one can fit in a sound bite on a debate stage.

So let's go into more detail, shall we? Here's Clinton's and Sanders's ongoing fight over the 2007 immigration reform bill, explained.

It has been described as Washington's last, best chance to overhaul America's immigration laws

After several years of sputtered starts, in 2007, Bush and Sens. Ted Kennedy (D-Mass.), Jon Kyl (R-Ariz.),John McCain (R-Ariz.), Lindsey Graham (R-S.C.) and then-Senate Majority Leader Harry Reid (D-Nev.), among others, spotted an opening to get immigration reform through Congress. Democrats had just taken control of the House of Representatives, which meant they controlled both chambers of Congress. All they had to do was override an expected Republican filibuster in the Senate and get the bill to Bush, who would sign it.

An expanding group of lawmakers and their staffs worked for months on a bill that eventually would have created a legal status for an estimated 12 million immigrants in the country illegally and a temporary worker program. It would also strengthen punishment for businesses that hired workers illegally and invest more to secure the border. Taken as a whole, the proposal was the biggest change to immigration laws in two decades.

But the complex bill was, perhaps necessarily, also huge. Like 761 pages huge. And as with many gigantic bills, it became an umbrella for all sorts of lawmakers' concerns and pet projects. Deals were cut, policies watered down or changed, and allegiances called into question. By the end, the bill split Republicans, Democrats, labor unions and immigration activists — sometimes down unpredictable lines.

One division that concerned Sanders happened when it comes to labor. The heavily immigrant Service Employees International Union supported the bill, while the AFL-CIO did not. Some immigration advocacy groups, like the influential League of United Latin American Citizens, expressed concerns as well. Executive director Brent Wilkes said at the time it "will separate families and lead to the exploitation of immigrant workers." (On Wednesday, Sanders cited LULAC's opposition as evidence that voting against the bill did not make him anti-immigration reform.)

Sanders sided with the labor unions concerned about the guest worker program

The program would would have allowed businesses to apply for visas for workers for up to two years at a time.

Today, he likes to talk about his opposition to it in humanitarian terms, calling guest-worker programs semi-slavery. But at the time, Sanders's public comments reflected on the economics of the program — specifically, his concern that bringing in guest workers would drive down wages for low-income Americans. Here's what he said on the Senate floor at the time:

It is not about raising wages or improving benefits. What it is about is bringing into this country over a period of years millions of low-wage temporary workers with the result that wages and benefits in this country, which are already going down, will go down even further.

A top immigration official at AFL-CIO told Politico that Sanders "was basically our ally."

(At Wednesday's debate, Clinton called Sanders's explanation an "excuse" not to vote for the bill.)

The divisions Sanders navigated happened many, many times over, as senators tried to balance their constituency, interest groups and their own personal beliefs about the bill in what was becoming an increasingly messy and personal debate.

Voting day was as chaotic and emotionally fraught, as the months of debate leading up to it had been

Senators were actually voting on a procedural motion to end debate, so that they could vote on the actual bill later. But because of Senate rules and the hype that had built up around it on both sides, the vote quickly became a referendum on immigration reform itself. From The Washington Post's coverage of the day:

A flood of angry phone calls from opponents of the overhaul shut down the Capitol switchboard before the vote, overwhelming the message from a small klatch of immigrant-rights demonstrators urging passage outside the Capitol. Latino lawmakers from the House flooded onto the Senate floor to encourage senators to keep the legislation alive and let the House have a turn.

The vote was expected to be razor-thin. But as soon as two undecided GOP senators voted against it, the whole thing came tumbling down. Supporters fell 14 votes short of the 60 needed to move forward. Fifteen Democrats, 37 Republicans and one independent — Sanders — voted against it.

Bush and the bill's supporters were dejected

"A lot of us worked hard to see if we couldn't find a common ground — it didn't work," the president said.

But then-Senate Minority Leader Mitch McConnell (R-Ky.) described what happened to it best: " I had hoped for a bipartisan accomplishment, and what we got was a bipartisan defeat."

The bill's failure arguably helped harden stances on both sides that has dimmed the chances for immigration reform today.

But immigration reform activists — and Sander — would get another chance in 2013, when the Democratic-controlled Senate passed a reform bill (that didn't get a vote in the House of Representatives). It, too, had a guest-worker program. But this time, most labor groups supported it. And Sanders voted for it.