Solicitor General Elena Kagan said in the brief to the Supreme Court that her office agreed with the United States Court of Appeals for the Second Circuit “that the princes are immune from petitioners’ claims,” although she pointed to somewhat different legal rationales in reaching that conclusion.

Ms. Kagan noted that the Supreme Court had historically looked to the executive branch to take the lead on such international matters because of “the potentially significant foreign relations consequences of subjecting another sovereign state to suit.”

The government said in its brief that the victims’ families never alleged that the Saudi government or members of the royal family “personally committed” the acts of terrorism against the United States “or directed others to do so.” And it said the claims that were made  that the Saudis helped to finance the plots  fell “outside the scope” of the legal parameters for suing foreign governments or leaders.

Justice Department officials declined to address the issue of whether the timing of the brief was related to Mr. Obama’s trip to Riyadh, but other lawyers involved in the case said the timing appeared to be coincidental. They said as a practical matter the department, which was invited to state its views in the case in February, needed to do so by this week if it hoped to influence the court’s decision on whether to accept the case before it leaves for summer recess in June.

William H. Jeffress, a Washington lawyer who is representing Prince Turki Al-Faisal, a former Saudi ambassador to the United States who is one of the princes named in the lawsuit, said the Justice Department came down on the right side of the law in supporting immunity.

Any suggestion that the timing of the brief was influenced by Mr. Obama’s upcoming visit was “baseless,” Mr. Jeffress said, as were the accusations in the lawsuit itself about the Saudi ties to Al Qaeda. “Osama bin Laden is a sworn enemy of the royal family of Saudi Arabia, and the idea that they would be providing financial support to Bin Laden is a little absurd,” Mr. Jeffress said.