WASHINGTON — As federal prosecutors face skyrocketing immigration caseloads along the southwestern border, the Defense Department agreed Wednesday to help the Justice Department prosecute the cases.

Twenty-one lawyers for the Defense Department “will work full time, assisting in prosecuting reactive border immigration cases, with a focus on misdemeanor improper entry and felony illegal re-entry cases,” the department said in a statement. The assignment is to last for about six months.

The Justice Department had asked for the help in anticipation of a surge in cases after Attorney General Jeff Sessions announced a “zero tolerance” policy in April.

“A crisis has erupted at our southwest border that necessitates an escalated effort to prosecute those who choose to illegally cross our border,” Mr. Sessions said at the time.