Defense Secretary Robert M. Gates speaks to troops from the U.S. Army 25th Infantry Division during a visit to Baghdad on Thursday. (CHIP SOMODEVILLA/GETTY IMAGES)

Defense Secretary Robert M. Gates warned a group of U.S. forces here Thursday that a government shutdown could delay the issuing of paychecks to military personnel.

A question about the standoff between President Obama and Congress came up in a question-and-answer session that Gates held with about 175 troops at Baghdad’s Camp Liberty. The government is scheduled to shut down normal operations at midnight Friday if no deal is reached.

“First of all, you will get paid,” Gates said, joking that it’s wise for governments “to always pay the guys with guns first.”

But he added that a shutdown would mean that military personnel would get partial paychecks for the first half of April. If a shutdown lasted through the second half of April, paychecks would stop until the federal government resumed normal operations. Any missed pay would be reimbursed at that time.

Military paychecks generally arrive on the first and the 15th day of each month, although they come earlier if those dates land on holidays or weekends.

Gates said that any interruption would hurt military families.

“A lot of these young troops live pretty much paycheck to paycheck,” he said, adding, “So I hope they work this whole thing out.”

He declined to comment on whether he is frustrated with Congress for not reaching a deal yet. “I’m not going to wade into that swamp,” he said.

On Friday, Gates visited U.S. troops posted in Mosul in northern Iraq, and the top question from them again was on the effects of a government shutdown.

“The good news is you will get paid. The bad news is you may not get paid on time,” Gates answered. “This troubles me a good deal.”

In his remarks in Baghdad on Thursday, Gates noted the relative calm in the Iraqi capital amid the U.S. military’s gradual pullout from Iraq, with a year-end deadline set for the departure of the remaining 47,000 troops. U.S. combat operations ended last year, although many still leave bases for training operations with Iraqi soldiers.

Gates said the United States is open to continuing a smaller U.S. presence if Iraqi officials make a formal request, preferably soon. U.S. Ambassador James F. Jeffrey told Gates in a meeting Thursday that U.S. forces are “the glue” holding Iraq’s security together.

In his remarks to the troops, Gates recalled that during his first visit as secretary, in December 2006, a firefight was taking place in the background at a similar event.

About one third of the troops he addressed Thursday were from the Army’s 2nd Brigade, 1st Infantry Division.

“This brigade lost 100 soldiers during the surge, but the difference you and those around you made in this country is evident around you every single day,” he said. “This has been an extraordinary success story for the U.S. military.”