The city of Denver has agreed to pay $300,000 to a United Airlines pilot who was arrested on an indecent exposure charge that was later dismissed by a judge.

Andrew Collins' attorney, Craig Silverman, announced the settlement Monday.

Collins, who served in the U.S. Air Force, was arrested Sept. 20, 2018, by Denver police and accused of indecent exposure for standing naked in front of his 10th-floor hotel window overlooking the Denver International Airport terminal. Collins spent days in the Denver city jail after his arrest.

Captain Andrew Collins, a pilot with United Airlines, was arrested for indecent exposure at a hotel at the Denver International Airport in September 2018. Denver Police Department

Ryan Luby, a spokesman for the City Attorney's Office, said the $300,000 payment comes from an insurance policy Denver has at the airport.

"We agreed on that figure in mediation on Friday," Luby told NBC News.

NBC News was referred by the Denver Police Department to a spokeswoman for Denver International Airport, who said the settlement was paid as part of the airport’s liability insurance because the incident took place on its property. She declined to comment further.

Silverman told NBC News on Tuesday his client was unaware he could be seen when he opened the curtains of his hotel room in the late morning that September day.

Collins, of Leesburg, Virginia, was naked and about to shower when he received a phone call, according to Silverman.

"Captain Collins walked around his room and took in the view as he was absorbed in the 24-minute phone call," Silverman wrote in a notice of claim dated March 15, 2019.

After the call ended, Collins was going to shower when he was alarmed by a Denver police officer loudly banging on his door and ordering him to open it. The officer told Collins he would enter with or without permission, the notice of claim states.

Collins, now dressed in pants and no shirt, opened the door, and "was immediately confronted and rushed" by the officer, according to the notice of claim, citing police body-camera footage.

Witnesses inside the airport had told police they could see a naked man in an upper floor window of the Westin Denver International Airport.

Collins' attorney said his client was unable to see anyone observing him from the airport terminal, which is more than 100 yards away.

Under Colorado law, a person commits indecent exposure if they knowingly expose their genitals to the view of any person, under circumstances in which such conduct was likely to cause affront or alarm to the other person, with the intent to arouse or satisfy the sexual desire of any person, the notice of claim states. While there was nudity in this case, it was not sexual, Silverman said.

"Captain Collins thought he was alone and not in anyone’s view," the notice of claim states. "It is not a crime to be naked in Denver. It is certainly not a crime to be naked in one’s hotel room."

Collins pleaded not guilty and a judge dismissed the misdemeanor charge in March. But he was suspended for six months from United Airlines as a result of the incident.

"Though the city of Denver may deny liability, it has now paid a price for what happened on Sept. 20, 2018," his attorney said in a statement.