In 2007, Hillary Clinton defended her South Carolina presidential campaign against allegations of endorsement-buying after her campaign entered a $10,000-a-month consulting contract with state Senator Darrell Jackson, a Columbia lawmaker and pastor who also operated a consulting company.

“Senator Jackson was someone who was involved in my husband’s campaigns,” Mrs. Clinton said at the time. “He was someone we turned to for political advice and counsel and I’m proud to have him on my team.”

At times the practice can cross legal boundaries: A former Iowa state senator was sent to prison in 2017 after a federal investigation revealed he had taken more than $70,000 from Ron Paul’s presidential campaign and that the money had been paid to an audio-visual production company to hide the payment from public view. Three former aides to Mr. Paul were also convicted of public corruption charges.

Mr. Sanders’s campaign said it was pleased with its connection to the two South Carolina lawmakers. “We’re proud that two leaders who endorsed in 2016 are not only supporting the senator again in 2020 but also working hard to help us win,” said a statement issued on behalf of the campaign by Nina Turner, a former Ohio state senator and a campaign co-chair.

Several current and former black elected officials expressed concern, though, that payments to officials who also endorse candidates, however legal, could create the impression that their support can be bought.

“I’m 75 years of age, and all my life you’ve had candidates come into the predominantly black community and dropping out a few dollars or a lot of dollars to a few people,” said Bernice Scott, a former member of the Richland County, S.C., council who supports Mr. Biden. “Call it consulting or whatever they want to call it, I wouldn’t do it. It puts a bad taste in everybody’s mouth.”

Mr. Steyer, a billionaire who is largely self-funding his campaign, has spent lavishly in South Carolina on advertising and staff and has also retained Harold Mitchell, an environmental activist and former state senator from Spartanburg who starred in an ad for Mr. Steyer, endorsing the former hedge fund manager.