The Arizona law, signed in April, makes it illegal to be in the state without proper immigration papers, and requires local police to determine whether people are in the country legally.
Critics say the law will encourage racial profiling - about 30 percent of Arizona's population is Hispanic - and that it gives too much power to local police. Federal officials are responsible for enforcing immigration law in the US.
US officials said they took the action after consulting with various law enforcement departments, chiefs of police, civil rights groups and other local officials.
Many apparently said that they were concerned the law would make victims of crimes or witnesses less likely to contact or co-operate with law enforcement.
Officials in Arizona say the law is necessary because of an influx of illegal immigrants from Latin America.
Eric Holder, the US attorney general, acknowledged in a statement that federal immigration policy has failed to stop the problem.
"Arizonans are understandably frustrated with illegal immigration, and the federal government has a responsibility to address those concerns," he said.
However, he added, "diverting federal resources away from dangerous aliens such as terrorism suspects and aliens with criminal records will impact the entire country's safety".
Arizona's two US senators, John McCain and Jon Kyl, both Republicans, issued a statement condemning the lawsuit.
"The American people must wonder whether the Obama administration is really committed to securing the border when it sues a state that is simply trying to protect its people by enforcing immigration law," they wrote.
Jan Brewer, the Arizona state governor, also criticised the suit as "a massive waste of taxpayer funds".
"It is wrong that our own federal government is suing the people of Arizona for helping to enforce federal immigration law," she said.
"As a direct result of failed and inconsistent federal enforcement, Arizona is under attack from violent Mexican drug and immigrant smuggling cartels."
A recent opinion poll by the Pew Research Center indicated that 59 per cent of US citizens support the law, which is scheduled to take effect on July 29.
Barack Obama, the US president, called for an overhaul of the immigration system in a speech on July 1, but republicans accused him of "political pandering" ahead of legislative elections.