The Navy SEAL who wrote a best-selling book detailing the secretive raid that killed al-Qaida leader Osama bin Laden must pay the federal government at least $6.8 million under a deal reached Friday to avoid prosecution for not getting pre-publication approval for the work.

The deal had been expected, and was outlined in a six-page decree filed in federal court in Alexandria, Virginia. It ends a nearly four-year saga for Matthew Bissonnette that began with the publication of “No Easy Day: The Firsthand of the Mission that Killed Osama bin Laden” one year after the raid. Bissonnette ran afoul of the law for not adhering to a nondisclosure agreement he signed as a SEAL that stated that he would submit any work for review by the Pentagon to make sure no classified information was revealed.

A decree signed by both federal authorities and Bissonnette and filed Friday said the SEAL and the government reached the deal after “extensive negotiations.” It holds that Bissonnette must pay $2.76 million within 30 days, and an additional $1.38 million within six months. He also must file amended tax returns within six months that all of the proceeds he made on the book belong to the United States.

Bissonnette, who wrote the book under the pen name “Mark Owen,” also agreed to pay the government $100,000 for a presentation on leadership that he gave that used slides that included information that was not submitted for Pentagon review first, the decree adds.

The agreement “does not discredit Mr. Bissonnette’s military service, but reinforces that it is important for our service members and individuals who have been assigned positions of trust and granted access to classified information to comply with the obligations set forth in their non-disclosure agreements,” Justice Department spokeswoman Nicole Navas said.

The Pentagon referred comments to the Justice Department. The news was first reported by the Daily Beast, which added that Bissonnette also must pay $1.3 million to the government in legal fees, which he paid using profits from the book.

A lawyer representing Bissonnette on the case, Robert D. Luskin, did not respond to requests for comment Friday. Bissonnette told the Daily Beast that previous accusations that he leaked classified information in the book have gone away.

“After the initial accusations of me leaking all that classified stuff … they found nothing,” Bissonnette told the Daily Beast. “They were just upset with me and wanted to get me one way or another. For four years, they looked into every little thing. Now … one signature and it all goes away,” he said.

The Justice Department previously dropped two other investigations into Bissonnette, including one this year that scrutinized whether consulting work he had done while still on active duty violated conflict of interest laws. He served in SEAL Team 6, known in the military as U.S. Naval Special Warfare Development Group.

Last summer, federal prosecutors in southern California reached a separate agreement with Bissonnette in which he would not be charged for what they considered the unauthorized release of classified information in exchange for returning the proceeds he earned.