Ramon Maldonado, of Phoenix, smiles as he holds up his new temporary Arizona driver's license after passing the required tests as he leaves the Arizona Department of Transportation Motor Vehicle Division office, Monday, Dec. 22, 2014, in Phoenix. Monday marked the first day that about 20,000 immigrants in the country illegally who have received protection from deportation could apply for Arizona licenses. (AP Photo/Ross D. Franklin)

A line stretches outside an a Arizona Department of Transportation Motor Vehicle Division office, as many young immigrants protected from deportation under new Obama administration policies begin pursuing Arizona driver's licenses, Monday, Dec. 22, 2014, in Phoenix. Monday marked the first day that about 20,000 immigrants in the country illegally who have received protection from deportation could apply for Arizona licenses. (AP Photo/Ross D. Franklin)

Erika Andiola gets her portrait taken at the Arizona State Capitol on Dec 17, 2014, in Phoenix, Ariz. Thousands of young immigrants moved a step closer to getting driver's licenses in Arizona when the U.S. Supreme Court on Wednesday rebuffed the governor's latest attempt to deny them the privilege. (AP Photo/The Arizona Republic, Nick Oza) MARICOPA COUNTY OUT; MAGS OUT; NO SALES

PHOENIX (AP) – They waited in line in the dark outside motor vehicle offices, cheered when the doors opened and celebrated again upon passing their driving tests.

For many young immigrants in Arizona, Monday marked a landmark day as they were able to get driver's licenses for the first time.

Arizona was one of the last states in the country where officials refused to issue driver's licenses to young immigrants who were brought to the U.S. illegally as children but allowed to remain in the country under a 2012 Obama administration program.

Republican Arizona Gov. Jan Brewer waged a lengthy legal battle over the program to restrict licenses. Courts ruled against the state on several occasions and cleared the way for licenses to be issued Monday.

Immigrants said they were excited about getting a license after driving to their jobs without one and fearing they would be pulled over.

"It's going to be ... peace of mind knowing that I'm legally allowed to drive now, not having to watch over my back and think of, 'Oh, am I going to get pulled over and get a ticket, get my car towed, and how am I going to get to work the next day,'" said Jose Cazares, 21.

After lining up in the dark outside Motor Vehicle Division offices, the immigrants filled out paperwork then took written exams and driving tests, performing parallel-parking maneuvers surrounded by TV cameras.

"It feels pretty nice knowing that I finally have the piece of paper that I have been waiting for over two years," 19-year-old Ramon Maldonado said as he emerged with a license.

Jose Alberto Aguilar, a Mexico City native who was brought to the U.S. by his parents as a child, waited at a Motor Vehicle Division office in Tucson. The 23-year-old civil engineer rides the bus to work each day.

"It's great because it allows me to get a car and be safer too," he said.

Aguilar said he was hired as a civil engineer after an internship made possible when he acquired a Social Security number through the Obama administration program that he said "really opened a lot of doors for me."

State officials expect the rush of applicants to continue in the weeks ahead since about 20,000 immigrants could be eligible for driver's licenses.

A preliminary injunction issued Thursday by U.S. District Judge David Campbell barred the state from enforcing Brewer's license policy.

Young immigrants have said the policy made it difficult or impossible for them to get essential things done, such as going to school, work or the store. Others were thrilled to have a form of state-issued identification that makes their everyday lives easier.

Brewer moved to deny the driver's licenses after the Obama administration took steps to shield thousands of immigrants from deportation.

The president's policy applied to people younger than 30 who came to the U.S. before turning 16; have been in the country for at least five continuous years; are enrolled in or have graduated from a high school or equivalent program; or have served in the military.

In the nation's most visible challenge to Obama's deferred-action program, Brewer issued an executive order in August 2012 directing state agencies to deny driver's licenses and other public benefits to immigrants who get work authorization under the Obama policy.

Her attorneys have argued that the decision grew out of liability concerns and the desire to reduce the risk of the licenses being used to improperly access public benefits.

Despite her belief that issuing licenses is a state matter, Brewer's office confirmed she would comply with the latest development. However, she is asking the U.S. Supreme Court to review her appeal.

Nebraska is the only other state to have made similar denials, and a federal judge this year dismissed a lawsuit contesting that state's policy.