Gov. Cuomo on Wednesday granted clemency to 61 convicted criminals — including 18 illegal immigrants who faced deportation but could now be home free.

The governor also pardoned 39 people who committed misdemeanors and nonviolent crimes when they were 16 or 17 years old but have since remained crime-free for 10 years or more.

And he commuted the sentences of two indi­viduals.

“These New Yorkers have proved their rehabilitation, in some cases for decades, but have been unable to gain legal status or fully re-enter society due to the stigma of conviction,” Cuomo said in a statement.

His action was seen as a shot at President Trump’s hard-line immigration stance, which includes stepped-up deportations of criminals, tougher vetting at the border, a ban on immigration from six ­Muslim-majority countries and building a wall on the Mexican border.

“While the federal government continues to target immigrants and threatens to tear families apart with deportation, these actions take a critical step toward a more just, more fair and more compassionate New York,” Cuomo said.

The Governor’s Office said the pardons to those facing deportation should allow them to eventually gain legal status, although there are no guarantees.

Those pardoned include Lorena Borjas, 57, who was convicted of criminal facilitation in 1994, as a result of being entrapped as a victim of human trafficking.

Borjas, a transgender woman from Mexico, has since become an advocate for transgender and immigrant communities across the country, running HIV-testing programs for transgender sex workers, and syringe-exchange programs for trans women taking hormone injections, Cuomo’s office said.

Another person facing deportation, Alexander Shilov, 35, was convicted of petit larceny and attempted petit larceny, from 2000 to 2004.

But Shilov has stayed clean for the past 13 years and works as a nurse at a Brooklyn long-term managed-care provider.

Advocates for inmates and immigration reform hailed Cuomo’s actions.

“Too many immigrants with prior criminal convictions are subjected to the gratuitous punishment of deportation, despite being longstanding contributing members of our community,” said Nick Turner, president of the Vera Institute of Justice.

It wasn’t the first time Cuomo pardoned a convict facing deportation.

In June, he pardoned Carlos Cardona, a former Ground Zero rescue worker who had a criminal conviction for a nonviolent drug crime in 1990.

Last year, Cuomo issued 101 pardons at Christmastime.