Image caption Sergio Garcia worked in an almond orchard to fund his education

The supreme court of California has granted a law licence to an undocumented immigrant from Mexico who has lived for years in the US.

Sergio Garcia, 36, arrived in the US nearly two decades ago without papers.

He attended law school and passed the California bar exam, but has not yet been granted a visa.

Mr Garcia challenged a 1996 law barring illegal immigrants from receiving professional licences, a rule later changed by Governor Jerry Brown.

The new lawyer was born in Mexico in 1977 and brought to California less than two years later, according to a statement from the California supreme court.

He returned to Mexico with his family at age nine, but illegally re-entered the US when he was 17.

'Good moral character'

Mr Garcia's father, who had legally obtained resident status, filed for a visa on his son's behalf soon after.

I feel incredible, this is the best gift 2014 could bring for me Sergio Garcia

But because of a long backlog of applicants, Mr Garcia has not yet been granted a visa.

He picked almonds and worked in a grocery store to pay his way through university and Cal Northern School of Law, later passing the California bar examination on his first attempt.

Mr Garcia subsequently challenged a 1996 federal law barring people living in the US illegally from receiving professional licences from government agencies or with the use of public funds.

The federal government argued the California courts were funded by public money, thus precluding him from being granted a licence.

Meanwhile, Mr Brown signed a series of immigrant rights bills in October, including one allowing undocumented people to obtain law licences. That law took effect on 1 January.

On Thursday, the state's supreme court unanimously ruled in favour of Mr Garcia, determining he "possesses the requisite good moral character to qualify for a law licence".

Speaking to the BBC's Newsday programme, Mr Garcia called the ruling a "landmark historic decision".

"I feel incredible, this is the best gift 2014 could bring for me," he said.