Justice John Greaney didn't write the Supreme Judicial Court's landmark ruling making Massachusetts the first state in the nation to legalize same-sex marriage, but five years later, a passage from his concurring opinion is sometimes used by gay couples in their wedding ceremonies.

"We share a common humanity and participate together in the social contract that is the foundation of our Commonwealth," Greaney wrote. "Simple principles of decency dictate that we extend . . . full acceptance, tolerance and respect. We should do so because it is the right thing to do."

Greaney, 69, who retires today after nearly two decades on the state's highest court, says he never thought twice about critics who said the judges had overstepped their role as jurists and imposed their own liberal view of marriage on the public.

"It's a common accusation made against decisions that people don't like, that the judges are activists, they're trying to set social agenda, that they're usurping the role of the Legislature, etc.," Greaney said in an interview with The Associated Press during his final week on the bench.

"That's one side of the debate, and the other side of the debate is that the judges are holding back progress in society . . . so for every argument, there's a counter-argument," he said.

Greaney was a judge in state Housing Court, Superior Court, and chief justice of the Massachusetts Appeals Court before being appointed to the state's highest court in 1989 by former Governor Michael Dukakis. He wrote several major decisions for the SJC, including a 1993 ruling that recognized the rights of gay couples in Massachusetts to adopt children, and a 2007 decision upholding a $2 million libel verdict against the Boston Herald won by a superior court judge.

Greaney is leaving the SJC to join the faculty of Suffolk University Law School four months before he turns 70, the mandatory retirement age for SJC justices.

During oral arguments before the SJC, Greaney was known for letting lawyers know - in no uncertain terms - that their arguments were not going well.

"His questions from the bench really got right to the point," said David Frank, a former state prosecutor who now writes for Massachusetts Lawyers Weekly. "He is a judge who will be remembered as one who didn't give speeches on the bench, and he certainly did a good job of requiring the lawyer to answer those questions, whether they were easy or difficult."

Greaney cut a distinctive figure in the hallways of the John Adams Courthouse, where the SJC sits.

He sometimes dressed all in black, a tribute to singer Johnny Cash, whom he quotes liberally. To get to the courthouse, he commuted 100 miles each way, taking a Peter Pan bus from his home in Westfield each day for about two weeks out of every month.

Chief Justice Margaret Marshall said Greaney's extensive experience as a lawyer and a judge made him one of the court's strongest opinion writers.

"He has a grasp of wide areas of the law, very knowledgeable on criminal matters and many other areas of the law," Marshall said. "As a jurist, he is enormously respected."

Greaney grew up in Westfield, the son of an Irish immigrant who worked as a laborer. The family didn't own a TV and didn't have a car until Greaney bought a Chevrolet Nova after graduating from New York University Law School in 1963. He said he knew he wanted to be a judge since his days at the College of the Holy Cross in Worcester, where his professors "kept stressing that you have to do something with your life and contribute to society and the well-being of others."

After graduating from law school, Greaney worked for a Springfield law firm for 10 years before being appointed to the bench.

As a Superior Court judge, Greaney decided one of the first home-schooling cases in Massachusetts, ruling that an Amherst couple had a constitutional right to teach their two children at home rather than enrolling them in school. He also held about 60 public school teachers in Franklin in civil contempt and put them in jail for refusing to return to work during a strike.

"I was determined that teachers, as public officers who were sworn to uphold the law, should not strike," he said.

"Each one of them brings a certain important issue and new dimension that allows us to either interpret the law and settle it where there's a disagreement or ambiguity, or develop the common law in a new way," he said.