It has been described as the “I have a dream” moment for America’s transgender community. It was also a moment when Loretta Lynch sounded more like Barack Obama than Obama himself. Last Monday in Washington, the US attorney general delivered arguably the most powerful repudiation yet of attempts to deny people access to toilets that match their chosen gender identity. The first African American woman to be the top law enforcement official in the nation set the issue in the wider context of the struggle for civil rights. She drew parallels with Jim Crow laws, the American apartheid that sanctioned racially segregated bathrooms.

“Let me also speak directly to the transgender community itself,” she said, cutting a diminutive figure, barely five feet tall, against a deep blue curtain. “No matter how isolated or scared you may feel today, the Department of Justice and the entire Obama administration wants you to know that we see you; we stand with you; and we will do everything we can to protect you going forward. Please know that history is on your side. This country was founded on a promise of equal rights for all, and we have always managed to move closer to that promise, little by little, one day at a time. It may not be easy – but we’ll get there together.”

LGBT rights activists were moved to tears. The first black president has striven to set a tone of tolerance, diversity and equality, including the legalisation of gay marriage, and had now found his perfect messenger.

Those who have known Lynch, 56, for a long time were pleasantly unsurprised. The former attorney in New York, who has gone after everyone from mobsters to abusive police to world football dons, was shaped by three formative influences: religion, civil rights and a reverence for the law.

She was born in Greensboro, North Carolina, the daughter of a preacher and school librarian with high aspirations for her. But race permeated everything. Her father, Lorenzo, 84, told the Observer: “I grew up in a segregated culture and segregated society. I sat at the back of the bus, I drank water from a coloured fountain, I went to a coloured bathroom. It was separate all the way around. The attitude to us was not friendly. Whites would meet us at the door of the store: ‘What do you want?’ The law was used as a weapon of control and fear.”

Despite this, Lorenzo’s own father often took him to court to follow proceedings and see what the law could be when properly exercised. He, in turn, did the same for his daughter, Loretta. He reflected: “I was still taught to have faith in the law. I tried to show her the law is part of life and is becoming part of life for minorities. Use the law; do not fear the law.”

The other moral compass was Christianity: Lynch’s father is a fourth-generation Baptist minister and her brother, Leonzo, is a senior pastor. She grew up listening to her father’s sermons and witnessing him struggle for civil rights, particularly on behalf of teachers and academics. Reflecting on the current case, in which Lynch has filed a federal suit against North Carolina over a bill that bans transgender people from using a bathroom of a different gender from that stated on their birth certificate, Lorenzo commented: “She has a strong sense of right and wrong. The governor of North Carolina is trying to get re-elected. He’s speaking out of expediency and she’s speaking out of conviction.”

Lynch’s mother, Lorine, filled the family home with books. Lynch was bespectacled, curly-haired and studious or, as she once put it, “nerdy”. She did so well on a school entrance exam at six that teachers assumed she had cheated and made her retake it; second time around, she did even better. Lynch also had the best grades in her high school.

She is smart, she is hard-working, she has a real passion for people not getting a fair shake New York Senator Chuck Schumer

The hard work paid off. She graduated from Harvard, where her idea of fun was reading Chaucer in Old English, and went to Harvard Law School. She began her career as a litigation associate for a prestigious Wall Street law firm. But as she recalled in a speech last Saturday: “Late one night, on the heels of many other late nights, I actually passed out at my desk. I was taken to the hospital and diagnosed with exhaustion. And as I was recovering, I started to think about whether the work that I was doing was why I went to law school. Was this work really what excited me?”

The answer was no. Lynch went to work as a federal prosecutor in Brooklyn. It involved taking a 75% pay cut, but she had found her calling. After nine years she became US attorney for New York’s eastern district. Senator Chuck Schumer, who recommended her for the position, said: “She is smart, she is hard-working, she has a real passion for people not getting a fair shake. She doesn’t get up and scream and yell about it but she resolutely figures out how to make things better for them.”

In Lynch’s first year running the US attorney’s office came the case that made her name: the successful prosecution of white police officers who viciously beat and sodomised a Haitian immigrant, Abner Louima. It was one of the most high-profile and contentious police brutality cases the city had seen. At one point she had to be escorted out of the courtroom by US marshals for her own safety.

Lynch was attorney from 1999 to 2001 but, as a political appointee, was forced to stand down during the George W Bush presidency and return to private practice. With Obama’s election, she resumed the position from 2010 to 2015.

She tackled financial fraud, human trafficking, corrupt public officials and cybercrime. She helped convict the masterminds of a thwarted al-Qaida plot to attack the subway. She presided over the biggest mafia bust in New York history, bringing charges against 127 members and associates of seven organised crime families.

Not everything worked out, however. She spent years building a case against reputed mobster Vincent Asaro over a $6m heist in 1978 at John F Kennedy airport, a case immortalised in the film Goodfellas, only for him to be acquitted last year. She was also criticised over a deal with HSBC that spared the bank from criminal charges over money laundering. In a case where Citigroup was accused of misleading investors about securities containing toxic mortgages, her office again agreed a $7bn settlement that carried no charges.

In 2014, when Eric Holder stepped down after six years, she was tapped by Obama to become the 83rd US attorney general. Her confirmation took more than 50 days because of a protracted Congressional fight, a delay that the president described as “embarrassing”.

Finally, in April last year, Lynch was sworn in using a Bible that once belonged to African-American abolitionist and writer Frederick Douglass. Lorenzo was in attendance. Had he ever thought, back in the old segregated south, that such a thing would be possible one day? “I never dreamed it, never thought it, never imagined it. I don’t think she allows discrimination to define her. It bounces off you. You take note of it, you prepare to deal with it but you don’t swallow it.”

After just a month in the job, Lynch’s face was on TV screens and newspaper front pages around the world. She announced indictments against nine Fifa officials and five corporate executives, a scandal that rocked world football. She declared that officials at the governing body had engaged in “rampant, systemic, and deep-rooted” corruption. At a time of scepticism about America’s role as the world’s policeman, some were grateful to find it acting as the world’s prosecutor.

Lorenzo is not surprised by the scale of her ambition. “As a young person she was very forward-looking and very forward-speaking.” The family remains close. Lynch goes home for mother’s day and father’s day. Her parents regularly attend her speeches. She did not marry until she was 48, to Stephen Hargrove, who works in TV production, and has two stepchildren but no biological offspring. “We’ve never discussed that,” said Lorenzo. “I was raised in a family of eight. When you’re in a family of eight, you don’t make a fuss about it.”

For all her impact, Lynch’s time in the spotlight could be running out. Some Republicans have previously accused her of partisanship. Her handling of the FBI investigation of Hillary Clinton’s use of a private email server as secretary of state will be a crucial test. Should Donald Trump win in November, Lynch can expect to be out of a job.

But if Clinton prevails, she has a decent chance of staying on. Carl Tobias, a professor at University of Richmond School of Law, said: “She was a fine pick because she was ready for the challenge of being on the big stage. She wanted to do as much as she could on as many fronts as possible.

“When a new president comes in, the custom is to tender one’s resignation but I wouldn’t be surprised to see Hillary retain her. She’s earned that.”

THE LYNCH FILE

Born Loretta Elizabeth Lynch in Greensboro, North Carolina, on 21 May 1959. She was the middle of three children born to Lorenzo and Lorine Lynch, who once told the Washington Post: “I told Loretta that I picked cotton so she wouldn’t have to do the same thing.” In 2007 she married Stephen Hargrove, and has two stepchildren, Ryan and Kia.

Best of times Last year she became the first African American woman to become US attorney general. Senator Chuck Schumer said: “If there’s an American dream story, Loretta Lynch is it.” She made a flying start by taking on Fifa, with indictments against nine officials.

Worst of times Nominated by Obama, Lynch’s confirmation hearings dragged on for more than 50 days, a record in modern times, and led to allegations of racism.

What she says “If a little girl from North Carolina who used to tell her grandfather in the fields to lift her up on the back of his mule so she could ‘see way up high, granddaddy’ can grow up to become the chief law enforcement officer of the United States of America, we can do anything.”

- At her swearing in last year.

What others say “The law is her map; justice, her compass. She is tough, but she is fair. She is firm, but kind.” – Barack Obama, 2015.