The governor of the southwestern U.S. state of Texas has commuted the sentence of a condemned inmate, a rare occurrence in a state that carries out the most executions in the United States.

Rick Perry commuted Kenneth Foster's death sentence to life in prison on Thursday, hours before Foster was to die for the 1996 shooting death of a man in the city of San Antonio.

The murder occurred while Foster and three other young men were on a robbery spree. Foster, who drove the car they were traveling in, was sentenced to death under a Texas law that holds anyone associated with a murder equally responsible.

Perry issued his order after the state board of paroles voted to recommend commutation. He says the decision is "right and just," and questioned the law under which Foster was convicted.

The man who actually committed the killing was put to death last year.

Texas recently carried out its 400th execution since reinstating the death penalty in 1982. This is just the third time in Governor Perry's seven years in office that the state parole board has recommended commuting a condemned prisoner's sentence. He rejected one of those recommendations, involving an inmate who had been judged mentally ill.

Some information for this report was provided by AFP, AP and Reuters.