WASHINGTON—The White House will restore full access to a CNN reporter who had been denied entry to the building, sidestepping a legal fight over the freedom of press and the government’s ability to exclude individual reporters.

In response, CNN said it was withdrawing the federal lawsuit it filed when Jim Acosta, its chief White House correspondent, was banned after a testy news-conference exchange with President Trump.

The move amounted to a de-escalation by the White House, which just last week signaled it was prepared to continue a legal fight over its right to exclude Mr. Acosta even after a setback in federal court.

The White House said it had revoked Mr. Acosta’s press credential because of his behavior at a Nov. 7 press conference, not because of his coverage. But in court, government lawyers argued the White House had the authority to ban reporters from government property for any reason, setting up what could have become a landmark First Amendment case.

“This afternoon we have notified Jim Acosta and CNN that his hard pass has been restored,” said White House press secretary Sarah Sanders in a statement, using a term for a badge that grants daily access to the White House grounds. “We have also notified him of certain rules that will govern White House press conferences going forward.”