A federal judge ruled against four GOP candidates suing to get on Virginia's primary ballot on March 6. (Published Friday, Jan. 13, 2012)

A federal judge ruled four candidates who failed to get 10,000 voter signatures will be left off the Republican presidential primary ballot in Virginia.

U.S. District Judge John Gibney presided over an almost four-hour hearing Friday on Texas Gov. Rick Perry's lawsuit challenging Virginia's ballot qualifying requirements.

Perry sued last month after failing to get the signatures required get on the ballot. Newt Gingrich, Rick Santorum and Jon Huntsman also failed to qualify and joined Perry's lawsuit, asking Gibney to declare Virginia's law unconstitutional and add their names to the March 6 ballot.

Campaign officials for the four candidates testified that they likely would have succeeded had they been able to have out-of-state residents circulate petitions. Perry’s suit claimed that restriction violates his constitutional right to free speech and freedom of association.

In addition to 10,000 signatures -- more than any other state – candidates must get at least 400 from each of the state's 11 congressional districts.

Gibney indicated the residency requirement probably is unconstitutional but should have been addressed sooner.

“What troubles me is they're asking me to put them on the ballot when they didn't get the 10,000 signatures,” Gibney said. “That's kind of intrusive on state affairs. I don't see how the 10,000-signature requirement is unconstitutional.”

Lawyers for the candidates said adding them to the ballot is the only remedy if the judge found the residency requirement unconstitutional.

"You played the game, you lost and then complained about the rules," Gibney said.

Only Mitt Romney and Ron Paul qualified for Virginia's primary.

Attorneys for the Virginia State Board of Elections argued that adding four more names to the ballot would prevent elections officials from complying with a legal mandate to mail absentee ballots to military and overseas voters by 45 days before the election -- in this case, Jan. 21.

According to testimony from campaign officials, Perry's signature effort came up short when the manager of a company hired to collect signatures fell ill right before the deadline. Gingrich thought he had submitted enough signatures, but GOP officials determined that an employee of the signature-gathering firm hired by his campaign submitted 1,500 fraudulent signatures. Santorum failed to gather enough signatures, and Huntsman didn't even try because of the cost of hiring a firm to do the work.

The officials said those problems would not have occurred had they been able to use out-of-state volunteers to collect signatures.

Judge Gibney's ruling will be appealed.

Follow NBC Washington to get the latest news, events and entertainment anytime, anywhere: on air, online, and on Facebook // Twitter.