A federal judge denied a request Friday by four presidential candidates to add their names to Virginia’s Republican primary ballot.

Texas Gov. Rick Perry, former senator Rick Santorum (Pa.), former House speaker Newt Gingrich (Ga.) and former Utah governor Jon Huntsman Jr. failed to qualify for the ballot and sued the State Board of Elections and the state GOP.

U.S. District Judge John A. Gibney Jr. said the candidates should have challenged the qualification rules months ago when they realized that Virginia forbids out-of-state residents to collect signatures.

“Had the plaintiffs filed a timely suit, the court would likely have granted preliminary relief,” Gibney wrote in his ruling. “In essence, they played the game, lost, and then complained that the rules were unfair.’’

Gibney said he thought a provision requiring the candidates to use only state residents was unconstitutional, but none of the candidates had managed to collect the required 10,000 signatures. Only former Massachusetts governor Mitt Romney and Rep. Ron Paul (Tex.) qualified for the Virginia ballot.

Virginia, an increasingly important swing state, will hold its primary on Super Tuesday, March 6.

Virginia’s ballot-access rules, in place for four decades, are considered the toughest in the nation. Candidates must collect 10,000 signatures, with at least 400 from each of the congressional districts, while some other states only require candidates to pay fees or sign forms.

State officials said Friday that they would not have time to reprint and mail absentee ballots by Jan. 21 in order to get them out 45 days before the primary as required by state and federal law. Changes would cost hundreds of thousands of dollars.

“We remain disappointed that more Republican candidates are not on our primary ballot,’’ said Pat Mullins, chairman of the Republican Party of Virginia.

Perry’s campaign told state election officials that it had submitted 11,911 signatures, but the lawsuit says 6,000 were submitted. Officials testified that an employee of the Utah firm hired to collect signatures went into a diabetic coma and was unable to either collect all the signatures or turn them in.

Gingrich’s campaign said it submitted 11,050 signatures. But the Virginia firm hired to collect signatures included 1,500 signatures that appeared to be signed by one person.

A poll released last month showed Gingrich with a slight lead over Romney among Virginia Republicans in the race for president. The Quinnipiac University poll showed Gingrich at 30 percent and Romney at 25 percent among Republican voters.

Santorum and Huntsman did not submit signatures and failed to qualify for the ballot. Officials testified Friday that Santorum’s campaign collected 8,000 but did not turn them in because campaign officials knew they fell short. Huntsman’s campaign officials said they did not want to pay $100,000 to a firm to collect the signatures.

Gov. Robert F. McDonnell (R) and legislative leaders said they would be open to looking at changing the ballot rules for future elections during this year’s General Assembly session.

“There are a lot more important issues,’’ said House Speaker William J. Howell (R-Stafford).

“If someone is running for president of the United States, the leader of the free world, you would think they would understand the requirements,’’ said Sen. Ryan T. McDougle (R-Hanover), chairman of the Senate Republican Caucus.

Attorney General Ken Cuccinelli II (R) had initially said he would push a bill to ensure that more Republican presidential candidates would appear on the state’s ballot this year, but he later backed off.

The Democratic Party of Virginia certified President Obama’s signatures. He was the only Democrat to qualify for the ballot, so the state will cancel the party’s primary.