Short-lived strikes over threatened layoffs and forced overtime halted commuter trains into New York City and Chicago Friday, stranding thousands of morning commuters before courts and Congress forced trainmen back to work.

In Chicago, the United Transportation Union struck the Chicago & North Western railroad Friday after the morning rush hour and Congress intervened to impose a settlement, putting the trains inservice in time for a delayed evening rush hour.The House passed a Senate-approved a bill ordering strikers back to their jobs less than six hours after the walkout began, and President Reagan signed the measure into law shortly before 6 p.m. EDT.

Officials had hoped in vain the measure would become law in time to have trains rolling for the system's 41,000 commuters during the evening rush hour.

A federal court order ended the New York wildcat walkout hours after 800 track maintenance workers struck at 4 a.m. in an overtime dispute.