WASHINGTON — President Obama ended a tumultuous year in the nation’s capital by commuting the sentences of 95 federal prisoners and granting two pardons on Friday, building on his push to reorient the nation’s criminal justice system with a holiday season stroke of his pen.

The set of commutations was the largest of Mr. Obama’s presidency, and it more than doubled the number he has granted since taking office. Most of those who will be freed are nonviolent drug offenders given long sentences during an earlier crackdown on crime. Forty of them will be spared life terms.

The move came as the president is pressing for an overhaul of criminal justice laws to reverse decades of steep penalties that have packed the nation’s prisons and jails, disproportionately affecting African-American and Hispanic men. The vast majority of Friday’s commutations were given to criminals who have been imprisoned for more than a decade, behaved well in prison and would have been sentenced to fewer years under current rules.

At an end-of-the-year news conference on Friday before leaving town for a two-week break in Hawaii, Mr. Obama called the commutations “another step forward in upholding our ideals of justice and fairness.” He said he hoped to use his final year in office to pass bipartisan legislation revamping the federal criminal justice system.