New York (CNN) -- Robert "Joe" Halderman, the former CBS News producer accused of trying to blackmail comedian David Letterman, agreed Tuesday to plead guilty to attempted second-degree grand larceny in exchange for six months in jail, five years probation and 1,000 hours of community service.
"This is a serious sentence that properly reflects the crimes that Mr. Halderman has now admitted that he committed, and it is a fitting end to the case," said Letterman lawyer Daniel J. Horwitz.
During Tuesday's taping of his "Late Night" show, Letterman expressed gratitude and relief that the matter is over.
"Now, I'd never been involved in anything like this in my life, and I was concerned and full of anxiety and nervous and worried," he said. "And the people in the district attorney's office said, 'This will be handled professionally, this will be handled skillfully, and appropriately.' Well, the matter was resolved today, and they were exactly right -- it was handled professionally, skillfully and appropriately."
The 62-year-old singled out District Attorney of Manhattan Cyrus Vance Jr., former District Attorney Robert M. Morgenthau, the Special Prosecutions Bureau in the district attorney's office and the New York City Police Department.
Formal sentencing is slated for May 4.
In a separate statement, the former "48 Hours" producer admitted that he tried to extort $2 million from Letterman to keep quiet about the "Late Show" host's sexual affairs.
"On the morning of September 9, 2009, I gave a sealed envelope to Mr. Letterman's driver as he waited outside of Mr. Letterman's Manhattan home," Halderman said in the statement, called an allocution. "I asked the driver to give the envelope marked 'Privileged and Confidential' to Mr. Letterman.
"The envelope contained a number of documents, including a document I created entitled 'Treatment for a Screenplay.' This so-called treatment was just a thinly veiled threat to ruin Mr. Letterman if he did not pay me a lot of money.
"Later that month, on three different occasions I met with Mr. Letterman's lawyer, Jim Jackoway, to work out the details of the extortion. On October 1, 2009, I deposited a check for $2 million that Mr. Jackoway gave me.
"I knew throughout this time that I was not engaged in a legitimate business transaction with Mr. Letterman and that what I was doing was against New York law. I understand that my attempt to extort $2 million from Mr. Letterman violated his and his family's privacy. I promise to respect their privacy in the future."
Then-District Attorney Morgenthau said Letterman gave Halderman a $2 million check in October and Halderman deposited the money into a Connecticut bank account the day before he was arrested.
Halderman was released from jail on $200,000 bail in October.
Letterman announced the extortion plot on his CBS show in October and admitted to affairs with female staffers.
Halderman closed his statement by expressing "great remorse" and apologizing to Letterman and his family and to the family of Stephanie Birkitt, one of the women Halderman said had engaged in a sexual relationship with Letterman. Birkitt was an assistant to the talk show host and a former live-in girlfriend of Halderman.
The 27-year CBS veteran had initially been charged with first-degree attempted grand larceny, to which he pleaded not guilty in October. He could have faced 15 years in prison if convicted on the charge.
CNN's Julian Cummings contributed to this story.