Lynne F. Stewart, a radical-leftist lawyer who gained wide notice for representing violent, self-described revolutionaries and who spent four years in prison herself, convicted of aiding terrorism, died on Tuesday at her home in Brooklyn. She was 77.

Her son, Geoffrey Stewart, said the cause was complications of cancer and a series of strokes.

Ms. Stewart, who had been treated for breast cancer before entering prison, was granted a “compassionate release” in January 2014 after the cancer had spread and was deemed terminal. Doctors at the time gave her 18 months to live.

A former librarian and teacher, she had taken up the law in the cause of social justice after seeing the squalor in the area around the public school in Harlem where she taught. She built a reputation for representing the poor and the reviled, usually for modest, court-paid fees.

Believing that the American political and capitalist system needed “radical surgery,” as Ms. Stewart put it, she sympathized with clients who sought to fight that system, even with violence, although she did not always endorse their tactics, she said.