James Lloyd expressed gratitude after the contractor had finished installing a patio with pavers and a fire pit at his home in Baltimore County for $7,000.

“Just want to say thank you again to you and your team for the professionalism and quality workmanship!” Lloyd texted the contractor, Luis Hernandez, on June 12, 2020. “May God continue to bless you and yours.”

Six days later, though, some of the pavers had become loose.

So Hernandez agreed to come back to the house and fix them — in addition to adding an extra 2 feet around the fire pit for $1,400.

But on June 25, Lloyd, a Baltimore Police sergeant, threatened to arrest Hernandez if he did not refund $3,500 in an ordeal that lasted two hours, prosecutors said. Lloyd brought three fellow officers with him.

Lloyd, 47, of Gwynn Oak, a 22-year veteran of the department, entered an Alford plea on Wednesday in Baltimore County Circuit Court to misconduct in office with no agreement in place on the sentence. That means he maintained his innocence but agreed that the state had enough evidence to secure a conviction.

As part of the plea agreement, the Baltimore County State’s Attorney’s Office dropped charges of extortion and kidnapping and won’t weigh in at Lloyd’s sentencing.

Sentencing guidelines call for a punishment that ranges from probation to two years in prison.

“They shouldn’t be police. This is outrageous conduct,” Deputy State’s Attorney Robin Coffin said outside the courtroom. “If he’s unhappy with the work, take him to court like the rest of us do.”

Coffin described the sequence of events in a statement of facts she read during the hearing.

When Hernandez got to Lloyd’s home at 9:30 a.m. on June 25, there was a Baltimore Police undercover van partially blocking the driveway.

Officers Manuel Larbi and Troy Taylor were in plain clothes, with their badges and handguns displayed, inside the van. The two worked under Lloyd in the department’s Homicide Apprehension Unit.

Next, Lloyd went up to Hernandez and stated, “We have trouble.” Lloyd was also in plain clothes with his handgun visible and repeatedly asked Hernandez for his driver’s license. Hernandez asked Lloyd why he wanted it. “Because of this,” said Lloyd, who then took out his wallet and showed his badge.

Lloyd told Hernandez that his driver’s license was suspended because of child support and that law enforcement would arrest him and tow his truck.

That’s when Baltimore Police Detective Juan Diaz went to the backyard.

Lloyd demanded a full refund and summoned Taylor to the backyard. He had pulled up records showing that Hernandez’s driver’s license was suspended on Dashboard, a police database.

Taylor told investigators that he had done that at Lloyd’s direction. But Taylor denied that he knew that there had been a threat made to arrest the contractor if he did not repay the money.

Eventually, Diaz suggested that Hernandez could fix the problem if he paid back $3,500. “We can solve this,” Lloyd said, “give me a check.”

But Hernandez did not have any checks with him. Lloyd then asked what bank he used and had Taylor send directions to the nearest branch.

Lloyd drove Hernandez to a Navy Federal Credit Union that was 20 minutes away in an unmarked police vehicle.

“You are going to give me my money back, and I am going to give you your freedom,” Lloyd told Hernandez, prosecutors said.

Inside the bank, Hernandez texted Lloyd, “Mr. James what’s your last name. I gonna get a cashier’s check.” Hernandez then ran out to the car, surveillance video shows, because Lloyd was holding the contractor’s driver’s license.

Later, Lloyd made Hernandez sign a receipt indicating that the check was for a refund and repairs.

Hernandez later called a friend who was a Prince George’s County police officer. He told him to call Internal Affairs.

Records showed that the four police officers were on-duty at the time. But the work schedule later changed and indicated that Lloyd had been off.

The four officers are currently suspended, according to a Baltimore Police spokesperson.

Larbi and Taylor were not charged with crimes.

Meanwhile, prosecutors dropped the case against Diaz, 48, of Columbia, who had been set to go to trial Thursday.

“He’s relieved, thankful and extremely emotional,” said Tony Garcia, Diaz’s attorney, in an interview. “He was willing to stand his ground on the truth that he did nothing wrong.”

Garcia said his client has been suspended without pay and will seek immediate reinstatement.

Following the hearing, Matthew Fraling, Lloyd’s attorney, declined to comment.

Circuit Judge Robert E. Cahill Jr. will determine Lloyd’s sentence on July 18. Lloyd remains free on his own recognizance, according to online court records.