New York (CNN) CNN has filed a lawsuit against President Trump and several of his aides, seeking the immediate restoration of chief White House correspondent Jim Acosta's access to the White House.

The lawsuit is a response to the White House's suspension of Acosta's press pass, known as a Secret Service "hard pass," last week . The suit alleges that Acosta and CNN's First and Fifth Amendment rights are being violated by the ban.

The suit was filed in U.S. District Court in Washington, D.C. on Tuesday morning. It was docketed and assigned to Judge Timothy J. Kelly, a Trump appointee. The judge has given the defendants an 11 a.m. Wednesday deadline to file responses to the suit. He has scheduled a hearing for Wednesday at 3:30 p.m.

Both CNN and Acosta are plaintiffs in the lawsuit. There are six defendants: Trump, chief of staff John Kelly, press secretary Sarah Sanders, deputy chief of staff for communications Bill Shine, Secret Service director Randolph Alles, and the Secret Service officer who took Acosta's hard pass away last Wednesday.

The six defendants are all named because of their roles in enforcing and announcing Acosta's suspension.

"This is not a step we have taken lightly. But the White House action is unprecedented," CNN Worldwide president Jeff Zucker said in an internal memo to staff.

Sanders responded to the suit by saying that CNN is "grandstanding" by suing. She said the administration will "vigorously defend" itself. ( Read the White House's full response here.

In a statement on Tuesday morning, CNN said it is seeking a preliminary injunction so that Acosta can return to the White House right away, and a ruling from the court preventing the White House from revoking Acosta's pass in the future.

"CNN filed a lawsuit against the Trump Administration this morning in DC District Court," the statement read. "It demands the return of the White House credentials of CNN's Chief White House correspondent, Jim Acosta. The wrongful revocation of these credentials violates CNN and Acosta's First Amendment rights of freedom of the press, and their Fifth Amendment rights to due process. We have asked this court for an immediate restraining order requiring the pass be returned to Jim, and will seek permanent relief as part of this process."

The White House Correspondents' Association said it "strongly supports CNN's goal of seeing their correspondent regain a US Secret Service security credential that the White House should not have taken away in the first place."

CNN also asserted that other news organizations could have been targeted by the Trump administration this way, and could be in the future.

"While the suit is specific to CNN and Acosta, this could have happened to anyone," the network said. "If left unchallenged, the actions of the White House would create a dangerous chilling effect for any journalist who covers our elected officials."

Sanders pointed out that lots of other CNN reporters and producers have press passes. But to many journalists and press defenders, that's not the issue. Echoing the views of many journalists, the correspondents' association said the president "should not be in the business of arbitrarily picking the men and women who cover him."

Trump's actions and threats fly in the face of decades of tradition and precedent. Republican and Democratic administrations alike have had a permissive approach toward press passes, erring on the side of greater access, even for obscure, partisan or fringe outlets.

The ACLU, in a statement supporting CNN, said "it is un-American and unlawful for the president to expel a reporter from the WH briefing room for doing his job. It shouldn't take a lawsuit from CNN to remind the president of the First Amendment."

The legal battle

On CNN's side, CNN Worldwide chief counsel David Vigilante is joined by two prominent attorneys, Ted Boutrous and Theodore Olson. Both men are partners at Gibson, Dunn & Crutcher.

Last week, before he was retained by CNN, Boutrous tweeted that the action against Acosta was "angry, irrational, false, arbitrary, capricious content-based discrimination," and thus a clear violation of the First Amendment.

In an interview on Tuesday morning, Boutrous said CNN tried to resolve the matter privately, but the White House was not responsive so "we really had no choice but to sue."

"We didn't want to have to go to court. We wanted to just report the news," he said. "Mr. Acosta wants to report the news. CNN wants to report the news."

CNN's lawsuit cites, among other precedents, a 1977 ruling in favor of Robert Sherrill, a muckraking journalist who was denied access to the White House in 1966.

Eleven years later, a D.C. Court of Appeals judge ruled that the Secret Service had to establish "narrow and specific" standards for judging applicants. In practice, the key question is whether the applicant would pose a threat to the president.

The code of federal regulations states that "in granting or denying a request for a security clearance made in response to an application for a White House press pass, officials of the Secret Service will be guided solely by the principle of whether the applicant presents a potential source of physical danger to the President and/or the family of the President so serious as to justify his or her exclusion from White House press privileges."

There are other guidelines as well. Floyd Abrams, one of the country's most respected First Amendment lawyers, said case law specifies that before a press pass is denied, "you have to have notice, you have to have a chance to respond, and you have to have a written opinion by the White House as to what it's doing and why, so the courts can examine it."

"We've had none of those things here," Abrams said.

CNN's suit makes the same point.

White House's shifting rationales

Acosta found out about his suspension when he walked up to the northwest gate of the White House, as usual, for a live shot last Wednesday night. He was abruptly told to turn in his "hard pass," which speeds up entry and exit from the grounds.

"I was just told to do it," the Secret Service officer said.

Around the same time Acosta was denied entry to the White House grounds, Sanders announced the decision and claimed that he had behaved inappropriately at a presidential news conference earlier in the day.

At first Sanders accused Acosta of "placing his hands" on an intern who was trying to take a microphone away from him. In reality, Acosta held onto the mic, said "pardon me, ma'am," asked a followup question, then gave up the mic.

On Twitter, Sanders shared a distorted video clip of the press conference that didn't show the complete back-and-forth. The same video had been posted by an InfoWars personality two hours earlier.

The White House's rationale was widely mocked and dismissed by journalists across the political spectrum. And Trump himself has cast doubt on the rationale: He said on Friday that Acosta was "not nice to that young woman," but then he said, "I don't hold him for that because it wasn't overly, you know, horrible."

In Tuesday's response to the lawsuit, Sanders did not repeat her claim about Acosta "placing his hands" in the intern. Instead, she accused Acosta of being disrespectful and unprofessional.

As for the argument that Acosta isn't respectful enough, that justification "is not sufficient as a matter of law," CNN's lawsuit asserts.

"The content and viewpoint of CNN's and Acosta's reporting on the Trump administration—not his interaction with the staffer at the November 7 press conference—were the real reason the White House indefinitely revoked his press credentials," the suit states.

Acosta is on a previously scheduled vacation this week. He declined to comment on the lawsuit. Since his pass was suspended, he has continued to do part of his job, contacting sources and filing stories, but he has been unable to attend White House events or ask questions in person -- a basic part of any White House correspondent's role.

"Relevant precedent says that a journalist has a First Amendment right of access to places closed to the public but open generally to the press. That includes press rooms and news conferences," Jonathan Peters, a media law professor at the University of Georgia, told CNN last week. "In those places, if access is generally inclusive of the press, then access can't be denied arbitrarily or absent compelling reasons. And the reasons that the White House gave were wholly unconvincing and uncompelling."

Last Thursday, according to the suit, Zucker wrote to Kelly and requested reinstatement of Acosta's credentials. Zucker's message said that "no complaints were raised with CNN and there was no attempt to reach anyone at CNN before taking this unlawful action."

The next day, CNN sent a formal letter to the White House repeating the request and warning of a possible lawsuit.

Over the weekend, Acosta reported on the president's trip to France. Ahead of Trump's planned visit to an American military cemetery, he requested and received a credential from the French government, but was denied access by the Secret Service.

"It was not without irony to me that a U.S. White House correspondent who is an American citizen was denied access to a ceremony by his own government but was granted access by the government of France," CNN Washington bureau chief Sam Feist noted in a declaration attached to the lawsuit.

Feist said "Jim's ability to cover a public event of historic international importance was completely blocked by the White House."

A high-stakes case

David McCraw, the top newsroom lawyer at The New York Times, said instances of news organizations suing a president are extremely rare.

Past examples are The New York Times v. U.S., the famous Supreme Court case involving the Pentagon Papers in 1971, and CNN's 1981 case against the White House and the broadcast networks, when CNN sued to be included in the White House press pool.

The backdrop to this new suit, of course, is Trump's antipathy for CNN and other news outlets. He regularly derides reporters from CNN and the network as a whole. But he also seeks out attention from CNN and other outlets.

During his presidential campaign, Trump told CNN that, if elected, he would not kick reporters out of the White House. But since moving into the White House, he has mused privately about taking away credentials, CNN reported earlier this year. He brought it up publicly on Twitter in May, tweeting "take away credentials?" as a question.

And he said it again on Friday, two days after blacklisting Acosta. "It could be others also," he said, suggesting he may strip press passes from other reporters. Unprompted, he then named and insulted April Ryan, a CNN analyst and veteran radio correspondent.

"The revocation of Acosta's credentials is only the beginning," CNN's suit alleges.

Correction: The original version of this article listed the former director of the Secret Service as a defendant; the actual defendant is the current director.