In the White Room on NASA Kennedy Space Center's Launch Pad 39A, STS-128 Mission Specialist Jose Hernandez - a former migrant farmer from Stockton, Calif. - waits his turn to enter space shuttle Discovery during a launch rehearsal for his Aug. 25, 2009 launch.

Former NASA spaceflyer Jose Hernandez, who is running for a seat in the U.S. Congress out of California this year, can call himself an astronaut on the ballot, a judge ruled Thursday (March 29).

Hernandez, a Democrat, flew on the space shuttle Discovery's STS-128 mission in 2009 but left NASA more than a year ago, in January 2011. California Republicans had argued that Hernandez should not be allowed to list his occupation as "astronaut/scientist/engineer" on the ballot, the Los Angeles Times reported.

But Judge Lloyd Connelly disagreed, saying that Hernandez is an astronaut for "more than the time spent riding a rocket," according to the Times.

Hernadez is vying to represent California's 10th Congressional District, in the state's agriculture-heavy Central Valley. Hernandez knows the Valley and its leading industry well, having grown up picking fruits and vegetables all over California as the son of migrant farmworkers.

The former astronaut is running against Republican Jeff Denham, as well as independent Chad Condit, the Times reported.

California Republicans were critical of Judge Connelly's decision.

"Allowing a candidate out of nowhere to use the profession of 'astronaut' when he hasn’t served in that profession recently is akin to allowing someone to use a title of 'sailor' when they no longer own or operate a ship," California GOP spokeswoman Jennifer Kerns said in a statement, according to the Times.

Hernandez, for his part, said he was happy to move on. In a Facebook post written before the verdict came down, he expressed surprise at having to fight this battle in the first place.

"I always thought the hardest part of being an astronaut would be the training," Hernandez wrote. "I didn’t realize it was going to be proving it in court."

The publicity the case has generated cannot please the California GOP, which was likely seeking to minimize the sway Hernandez' astronaut background might hold in the voting booth, said space history expert Robert Pearlman, editor of SPACE.com sister site collectSPACE.com.

"This had everything to do with using 'astronaut' as a political advantage," Pearlman told SPACE.com. "If you didn't know he was an astronaut before, you probably do now."

You can follow SPACE.com senior writer Mike Wall on Twitter: @michaeldwall. Follow SPACE.com for the latest in space science and exploration news on Twitter @Spacedotcom and on Facebook.