Photo

The United Food and Commercial Workers International Union will endorse Hillary Clinton on Tuesday, giving the Democratic candidate a welcome boost as polls in Iowa and New Hampshire show Senator Bernie Sanders gaining ground.

The union, which represents 1.3 million members who work in retail food services, at food processing plants and in groceries across the country, will make its endorsement official Tuesday afternoon, less than three weeks before the Feb. 1 Iowa caucuses.

In an interview, Marc Perrone, the international president of the U.F.C.W., said he met with both Mrs. Clinton and Mr. Sanders and their campaign officials. On issues like retirement security and child care, the candidates lined up, he said.

“It then became a discussion of who had the best opportunity to win” the general election, Mr. Perrone said.

The endorsement of one of the nation’s largest labor unions, with a membership that is predominantly female and minority, comes as Mrs. Clinton works to solidify her support among black and Latino voters, who could bolster her candidacy after the first two contests in Iowa and New Hampshire.

She has already won the support of other major labor unions including the National Education Association and the American Federation of Government Employees, as Mr. Sanders has picked up the endorsement of liberal groups like MoveOn.org.

The U.F.C.W. did 14 focus groups with its members across the country and came to its decision on Monday. The union will encourage its Iowa-based members to get involved in Mrs. Clinton’s final stretch of campaigning before the Iowa caucuses and help on caucus night.

“We think if we’re going to be involved in the conversation, this is a good time for us to do that,” Mr. Perrone said.