A former police officer who stole his dead cousin's identity to get on the force will not go to prison but must leave the country, a judge decided Monday.

Oscar Ayala-Cornejo, 25, was charged in federal court with falsely representing himself as an American citizen after an anonymous tip led the U.S. Department of Homeland Security to him.

He was arrested May 31 and agreed to a plea deal about two weeks later. He was fired from the department in June.

On Monday, a judge sentenced him to a year of probation. The maximum sentence could have been three years in prison and a $250,000 fine.

Ayala did not fight deportation. He has said he plans to live with family in Mexico and study computer engineering.

Ayala apologized to his family, friends, the community and the police department.

"It was never my intention to do any harm to anybody," he told the judge.

Both Ayala's defense attorney and prosecutor told the judge that Ayala was family oriented, a decent person who made a mistake and had accepted responsibility for what he had done.

In a recent interview with The Associated Press, Ayala said his father helped him change his identity to Jose Morales, his cousin who died as a child of stomach cancer.

He told his father he wanted to become a police officer in high school after officers from the department came to the school to recruit for the police aide program.

The family moved from Guadalajara, Mexico in 1992 and their first neighborhood was rough. They lived next to a crack house, often heard gunshots and had their home burglarized.

"I wanted to change my neighborhood, to change other people's neighborhoods, so they could feel safe, you know," Ayala said recently. "Because I didn't feel safe. I was pretty passionate about that."

His sister was married to a citizen, his brother was born in the U.S., and his parents were on their way to becoming permanent residents. He would have had to go back to Mexico when he became an adult to wait 10 years or more to become a citizen and his father didn't want to separate the family.

Before his junior year in 1999, Ayala switched high schools, cut his hair, replaced his glasses with contacts, got braces and became more outgoing. He says he became a different person, along with a different name.

His father died of leukemia in 2004, before he could see his son become a police officer.

Ayala doesn't hold his father responsible.

"The cards that we were dealt just weren't the best ones," he has said. "If I wouldn't have done this, I would still be in Mexico waiting to see if I could ever see my family."

His 26-year-old brother, Alex, was fired from the department in September for withholding information about his brother. He's appealing.