Just before 10 a.m. on Saturday, January 8, 2011, Jared Lee Loughner got out of a taxi at a Safeway supermarket north of Tucson. He walked inside the store to get change for the fare. When he came out, he approached US Representative Gabrielle Giffords, who was greeting constituents near the entrance. He pulled out a Glock 19 semiautomatic pistol and began firing.

Giffords was struck in the head but survived. Six people were killed, including a federal judge, a Giffords aide, and 9-year-old Christina-Taylor Green. Loughner wounded more than a dozen others before bystanders tackled him. The attack, one in a string of mass shootings around the country, elicited shock. "If there are rain puddles in heaven, Christina is jumping in them today," President Obama told a tearful nation a few days later.

The 22-year-old Loughner was a local kid. He’d grown up in a middle-class home minutes from the Safeway and had attended community college nearby. Still, it was easy, after his unconscionable act of violence, to see the face of a monster in his disturbing mug shot grin. As if he had forfeited citizenship in the human race.

Two days after the shooting, a judge approved Judy Clarke as one of Loughner’s attorneys. Clarke, a San Diego-based lawyer widely considered one of the nation’s top criminal defenders, spent almost two years at Loughner’s side, guiding him through hearings, investigations into his mental competency, and preparations for a possible trial. Her objective was clear throughout: to save him from execution.

Loughner didn’t make it easy. Reuben Camper Cahn, a federal defender who worked alongside Clarke, said Loughner’s mental illness was among the most severe he’s seen in more than 25 years of practice. Clarke was in Loughner’s corner, but Loughner lunged at her on at least one occasion. He spat at her. He threw a plastic chair at a psychologist.

And yet Clarke and her team stuck by him anyway, like the old man in a Buddhist proverb who tries to save a drowning scorpion despite its repeated stings. Clarke’s persistence paid off. In August 2012, Loughner pleaded guilty in exchange for a sentence of life in prison without parole.

The outcome, to those who follow her career, was vintage Judy Clarke: Take on someone accused of a terrible crime, get to know his background intimately, and then persuade the judicial system to spare his life, on the basis that no one should be judged solely on his worst act. "It’s a hell of a fight as a defense lawyer," she once said.

That fighting spirit — challenging prosecutors, striving for understanding, sticking by people society has turned on — is what drives Clarke and defense lawyers like her to take on the most reviled defendants. And it animates the 62-year-old Clarke as she works to spare accused Boston Marathon bomber Dzhokhar Tsarnaev from the death penalty.

Clarke may not be a household name — she generally avoids the spotlight and did not respond to an interview request — but her clients are infamous. There was Susan Smith, the South Carolina mother who drowned her two children in 1994 by rolling her Mazda Protege into a lake — and then blamed a fictitious black carjacker. There was Ted Kaczynski, the so-called Unabomber, whose homemade devices killed three people and hurt many more. And Eric Rudolph, a serial bomber who killed two people and wounded many others, including at the 1996 Summer Olympics in Atlanta. She briefly assisted Zacarias Moussaoui, the 9/11 conspirator known as "the 20th hijacker."

Like Loughner, all avoided the death penalty. Clarke excels at humanizing her clients — getting juries, judges, and prosecutors to see defendants as the sum of their experiences. After detailing Smith’s abusive childhood and depression, she told a South Carolina jury: "We’re not trying to gain your sympathy. We’re trying to gain your understanding."

Within weeks of the April 2013 Boston Marathon bombing, Clarke had accepted Tsarnaev, then 19, as her newest notorious client. The case promised to be one of Clarke’s biggest tests yet. Here was a man accused of hiding a bomb behind an 8-year-old boy on Boston’s most cherished day.

It’s easy to understand what attracts some defense lawyers to their line of work. The appeal of challenging wrongful convictions is plain. The money, in some cases, can be good. The practice of representing run-of-the-mill criminals enjoys wide acceptance. But what of the worst offenders — the mass murderers, the child rapists, the terrorists? What compels people to defend them?

THAT AWFUL MONDAY in Boston will never be forgotten. Innocent people were slain in the street. Political leaders condemned their killings as "bloody butchery." The public outcry was fierce.

The year was 1770. On the wintry night of March 5, a small band of British soldiers clashed with a crowd of hundreds outside Boston’s Custom House. The soldiers opened fire and killed five men. What we now call the Boston Massacre presaged the battle for independence a few years later.

The day after the killings, John Adams, then 34 years old, was asked to represent the soldiers in court. "Adams accepted, firm in the belief, as he said, that no man in a free country should be denied the right to counsel and a fair trial," David McCullough writes in his 2001 biography of Adams. And yet Adams knew he would pay a price — namely that by taking the soldiers’ case, he risked, in his words, "incurring a clamor and popular suspicions and prejudices" against him, McCullough writes.

In the two and a half centuries since, fairness, due process, and the right to counsel have formed the bedrock of the American criminal justice system, guaranteed by the Constitution Adams helped shape. Adams himself set the example for generations of criminal defense lawyers like Clarence Darrow, who understood that taking on unpopular clients protected the integrity of the system and thus the rights of everyone else.

Few understood that better than Clara Foltz, who in 1878 became the first woman admitted to the California bar. Foltz concluded that criminal proceedings were stacked against defendants who couldn’t afford lawyers. After waging a long campaign, she established the role of public defender — necessary, she said, to ensure "exact, equal, and free justice."

A defendant’s right to a publicly funded lawyer, though, was not assured in every state until a landmark 1963 case known as Gideon v. Wainwright, named for Clarence Earl Gideon, a Florida man found guilty of a break-in at a pool hall. Too poor to hire a lawyer, his request for one was denied and he was forced to represent himself at trial. But the US Supreme Court said in a unanimous decision that state courts had to provide attorneys for indigent defendants. That requirement stands today, though the quality of public defenders varies widely. (Judy Clarke named a pet 100-pound giant schnauzer Abe in honor of Abe Fortas, the lawyer who successfully argued Gideon’s case before the Supreme Court.)

Once criminal defendants indicate they can’t afford a lawyer, it falls to the court to appoint one, usually in consultation with the local public defender’s office. Nationwide, lawyers say, federal courts generally ensure that defendants receive competent representation, while state courts are much less reliable.

Those accused of heinous crimes face the prospect of the death penalty, either at the federal level or in one of the 32 states that allow capital punishment. (Massachusetts does not.) In September, for instance, admitted serial killer Gary Lee Sampson, who was sentenced to death in 2003, returns to federal court in Boston for a retrial.

In federal death penalty prosecutions, courts must, by law, appoint so-called learned counsel — lawyers with experience trying capital cases who meet specific guidelines. Kevin McNally, director of the Federal Death Penalty Resource Counsel Project, a clearinghouse for attorneys, estimates that there are 75 to 100 lawyers across the country who fit the criteria.

About three-quarters of such appointees in current cases are, like Clarke, private attorneys who volunteer to take them on, according to US court system figures. They are paid no more than $181 an hour, ultimately by taxpayers. (Defense lawyers often earn far higher rates in private sector work.) The other 25 percent are defenders employed by nonprofit organizations or the federal government.

In the Tsarnaev case, a judge magistrate approved Clarke’s appointment in 2013 and then later agreed to his defense team’s request to add David Bruck, a longtime collaborator of Clarke’s whose sterling reputation matches hers. "They are the best of the best," says David Hoose, a Northampton attorney who represented Kristen Gilbert, a nurse convicted in 2001 of killing four patients at a Veterans Affairs hospital in Northampton.

The reasons Clarke, Bruck, Hoose, and their peers do this work are many. Some see it as social justice, a way to stand up to government power — and, at times, its abuse of power. Others may have felt marginalized in their own lives, or they identify with underdogs. Still others simply have a contrarian streak. All would tell you that defending the most hated criminals honors the Constitution. Many, including Clarke, are driven by deep opposition to the death penalty. (In Clarke’s cases, guilt is often not in dispute; instead, she is focused on winning life sentences.)

In a larger sense, defense lawyers say, zealous advocacy for defendants pushes the criminal justice system toward its infallible ideal. The prosecution has a duty in every criminal case to prove guilt beyond a reasonable doubt. Defense lawyers have a duty to poke, prod, and challenge the government’s assertions. Only then, the argument goes, will society have the clearest sense of what happened, what didn’t, and what punishment is warranted. That’s especially critical in capital cases, where prosecutors are often under immense pressure to win, says New York-based lawyer George Kendall, a death penalty specialist.

And though violent crime seems unlikely to ever shed its taboo, there have been periods in history — the Red Scare of the 1940s and ’50s, the civil rights movement — where lawyers took heat for representing defendants who would be perceived very differently today. "Zealous representation requires the lawyer to subordinate all other interests — ideological, career, personal — to the legitimate interest of the client," longtime defense attorney Alan Dershowitz, a professor emeritus at Harvard Law School, writes in an essay for the 2013 anthology How Can You Represent Those People? He goes on: "You are the surgeon in the operating room whose only goal is to save the patient, whether that patient is a good person or a bad person, a saint or a criminal."

JUDY CLARKE GREW UP IN Asheville, North Carolina, the second of four children in a politically conservative home. Her father, Harry, was president of an employers’ association, a church elder, and a friend of Jesse Helms, a US senator for many years. Clarke’s mother, Patsy, acted in the local theater and taught speech at a nearby university. Patsy had moved from Massachusetts as teenager. Her father, Russell Munroe, was born in Boston, graduated from Brookline High School, and managed theaters in Allston, Lawrence, and Adams, according to a 1938 profile in the North Adams Transcript.

In the Clarkes’ Asheville home, the family gathered around a big oak table in the kitchen. Here, over pot roast dinners or Boston cream pie, Judy, her siblings, and their parents and grandparents debated news, politics, and the meaning of a chosen "word of the day." The children were encouraged to speak their mind, and they did. Judy and her sister, Candy, shocked their mother in 1972 by voting for George McGovern.

Judy has said she wanted to be a lawyer from age 12. "I thought it would be neat to be Perry Mason and win all the time," she explained to the San Antonio Express-News. According to her mother, Judy inherited her father’s courage and presence. "He simply had an inner calm of knowing who he was, what he was about, and who he loved," Patsy Clarke would later write in a 2001 book. Judy graduated from Furman University and went on to law school at the University of South Carolina, graduating in 1977.

The family later suffered two tragedies. Harry Clarke died when his single-engine plane missed the runway returning from a business trip in March 1987. Seven years after that, Judy lost her 31-year-old brother, Mark, to AIDS. After Mark’s death, Patsy, at Judy’s urging, wrote to Helms and asked him to stop passing judgment on gays and lesbians and to support AIDS research. Helms replied that Mark had invited death by playing "Russian roulette in his sexuality." Patsy was furious. She went on to cofound a political group called Mothers Against Jesse in Congress.

Judy Clarke launched her legal career as a federal defender in San Diego in 1978, eventually leading the office as executive director. She later assumed a similar role in Washington state. "I love the action. I love the fight," she once told the Los Angeles Times, explaining her affinity for defense work. "Especially when it’s over an issue that I think is of significance to all of us, and that’s our freedoms, our individual liberties." Clarke and her husband, Tom "Speedy" Rice, a fellow lawyer, now shuttle between Lexington, Virginia, where they teach at Washington and Lee University School of Law, and San Diego, where they maintain a private practice. They do not have children.

By most accounts, Clarke, known for her pageboy haircut and colorful ties, loves the law, and the law is her life. When she’s not flying around the country on cases, she’s teaching or advising other lawyers who have sought her guidance. Friends and colleagues describe her as warm, funny, uncommonly generous with her time, and seemingly devoid of ego. She is, they say, the antithesis of a flashy criminal defense attorney.

Several years ago, Clarke asked Phoenix lawyer Larry Hammond to help with a complex death penalty case in San Diego, in which the reputed head of a Tijuana drug cartel was strongly implicated in a number of killings. The case posed massive challenges for the defense. On one particularly low day, Hammond ran into Clarke at a downtown coffee shop. Half-joking, he told her never to call him again. "She said something like, ‘Don’t kid me. This is the best and most important and interesting thing you’ve ever done.’ "

In court, Clarke is known as a dogged, detail-obsessed advocate, tenacious but professional. She enters a courtroom with credibility and leaves with it intact. She rarely speaks to the press — a strategy not all her peers agree with — but in the Susan Smith case, her defense team artfully used publicity before the trial to soften Smith’s image, says Tommy Pope, the prosecutor in the case. "They took Susan from Susan the Monster to Susan the Victim," he says. Clarke has said that the Smith case shaped her antipathy to the death penalty.

Clarke is famous for establishing a bond with her clients, teasing out information about psychiatric disorders, abusive childhoods, or whatever else might mitigate their crimes. She then builds arguments for mercy from what she’s learned. In the Loughner case, the defense team at one point pursued his family records from the 1890s, apparently trying to establish a pattern of mental illness. "She is probably the most patient person I have ever met," says Laurie Shanks, a professor emerita at Albany Law School who has known Clarke for nearly 35 years.

Over the past 21 months, Clarke has undoubtedly used that painstaking technique to build trust with Dzhokhar Tsarnaev and understand his troubled life. As of this writing, she and her team, which includes three Boston-based federal defenders, seem prepared to dwell on his broken family and cast his older brother, Tamerlan — who was killed in the Watertown firefight with police — as a nefarious influence.

On a Thursday morning in December, Dzhokhar was in US District Court in Boston for a pretrial hearing, his first such appearance in more than 18 months. He wore gray pants and a dark sweater over a white dress shirt. He came with a full beard. He fidgeted with his arms but otherwise appeared calm. Clarke sat next to him, and then David Bruck. Judge George O’Toole Jr. asked Tsarnaev a couple of basic questions. His answer each time was pro forma: "Yes, sir."

Then O’Toole asked Tsarnaev if he was confident his lawyers had been acting in his best interest.

IN 2006, A COLLEGE STUDENT named Christopher Porco was convicted of killing his father and maiming his mother in a brutal ax attack at their home outside Albany, New York. Laurie Shanks and her husband served as Porco’s defense team. "People detested us," she says. They got death threats. She was followed and photographed. Someone even put the name of her children’s camp on the Internet. It was terrifying.

The hostility underscored for Shanks what a hard time people have accepting that the Christopher Porcos of the world deserve the same rights everyone else does. Indeed, high-stakes criminal defense work is not for the faint of heart. In recent years, defense attorneys for a relatively new class of social outcast — accused terrorists and Guantanamo Bay detainees — have been the object of vitriol. "You have to be able to take the abuse and just keep coming back," says Stephen Gillers, a legal ethics specialist at New York University School of Law.

Some defense lawyers say they come to personally like their clients, viewing them in a radically different light than the public. Though society can treat good and evil as a dichotomy, human lives are more complicated, criminal defenders say. "Everybody started out as innocent, and things happen to you," says Jonathan Shapiro, a longtime criminal defender who has taught with Clarke at Washington and Lee. "It just becomes really clear as you’re sitting there in a maximum security cell with somebody that they’re just a screwed-up person. And the horror of the state putting the needle in their arm — it makes it very easy to do that kind of work morally."

Shanks says: "Almost always, the people we represent are broken. . . . They almost never have the same kinds of benefits that many of us had. To expect them to behave the way people who have all these privileges have is not realistic." Abbe Smith, who directs the Criminal Defense & Prisoner Advocacy Clinic at Georgetown University, says that buffering defendants from public outrage is a kind of calling — especially in cases with young defendants who have clearly lost their way. "Standing between the accused and the wrath of the community is a powerful thing," she says. "And it’s a very intimate thing."

One man who has stood there a lot is J.W. Carney Jr., a veteran Boston defense lawyer who has represented, among many others, John Salvi, who killed two women at Brookline abortion clinics in 1994, Al Qaeda supporter Tarek Mehanna, and, most notoriously, James "Whitey" Bulger. With Bulger, one of the most feared and despised men in recent Boston history, Carney knew he’d have to explain his profession as never before. The day he got the appointment, the weight of his task set his mind racing. On his way to Plymouth to meet Bulger for the first time, Carney got pulled over for speeding. The state trooper asked him why he was in such a hurry. Carney told him of his newest client. The trooper let him go. "Mr. Carney, you’ve got a lot more problems than a speeding ticket," the trooper said, according to Carney. "Good luck and godspeed."

As Carney built a rapport with Bulger, it helped that Carney knew his way around South Boston. He’d once worked on Ray Flynn’s mayoral campaign. Carney and Bulger talked about the neighborhood. Bulger would ask him if a certain pub was still around, and Carney would tell him, no, that’s a yuppie restaurant now. "He asked me about a person we both knew and said, ‘What’s he doing these days?’ " Carney recalls. "I replied, ‘I think 15 to 20.’ He laughed." Bulger’s upbringing, his relationships with his parents, his schooling — Carney wanted to know all of it, to help inform his defense. (Bulger was ultimately convicted of 11 murders, among other crimes, in August 2013 and received a double life sentence.)

Like many of his peers, Carney tries to glean as much as he can from his clients. He never instructs them to hold back on details or to obscure what they’ve done. That’s consistent, Gillers says, with the current practice of most defense lawyers. Knowing your client has done what he’s accused of, Gillers and others say, does not preclude you from defending him zealously. "Lawyers say, ‘No one is guilty until they’re found guilty at trial,’ " he says.

And what if a defense attorney does such a stellar job that a guilty client is acquitted? It doesn’t happen often, criminal defenders say, but it’s a necessary risk. Far better that a guilty person get off, they say, than an innocent one be put away.

THE FORCE OF THE BLAST blew Heather Abbott into Forum, the Boylston Street restaurant where she’d come to meet friends on Marathon Day. Her left foot, as she lay on the ground watching everyone flee, felt like fire. One week later, on April 22, 2013, she made the excruciating choice to amputate her leg below the knee.

Intellectually, Abbott understands that Dzhokhar Tsarnaev, charged with planting the crude bomb that changed her life forever, is entitled to a vigorous defense. But she has a hard time understanding how anyone could represent him. Whatever happened in Tsarnaev’s life, she says, cannot excuse what he and his brother allegedly did — kill four people and wound more than 260. "There are a lot of people that have screwed-up upbringings and have people in their lives that do bad things, and it doesn’t mean they do," she says. "He was 19. He was an adult. He made the decision to do it."

Those who know Judy Clarke say that she has always been sensitive to those hurt by the people she defends. The Boston bombing case is no different, says Jon Sands, a federal defender in Arizona who has known Clarke for about 30 years. "She is fully cognizant of the pain and suffering of the victims," he says. "She has to take all of this in."

Despite what people often assume, defense lawyers say they are capable of caring deeply about both defendant and victim. It’s born out of the same empathy. Both figures, in their eyes, have at least one thing in common: They’ve been shaped by forces outside of their control.

During the John Salvi trial, in 1996, Carney, Salvi’s lawyer, came to the Dedham courthouse each day and greeted the parents of one of the women his client was charged with killing. Carney would nod and say good morning. They were on opposing sides, in a sense, but civility had its place.

Carney’s defense strategy was to show that Salvi’s mental illness, not ideology, caused him to shoot up the abortion clinics. On one particular day in court, Carney says, a witness gave powerful testimony about Salvi’s delusional, paranoid rantings at a church Mass. Carney made eye contact with the victim’s parents afterward. He felt that they understood that Salvi was not some rabid antiabortion activist but a deeply disturbed young man.

Leaving Dedham that day, Carney pulled onto Route 128 and headed north to go home. He began to think about what it would be like if his own daughter had been one of Salvi’s victims. He started to sob uncontrollably. He had to pull over to the side of the highway. It was pouring rain. He started berating himself. "Look, you’re a criminal defense lawyer. This is the business you chose," he told himself. "Just do your job."