DETROIT—This week, union workers at a Ford manufacturing plant outside Detroit raced to set up new assembly lines. But instead of making hybrid car batteries, the usual output from the factory, they are preparing to churn out tens of thousands of ventilators, joining the sprint against the clock to fight the coronavirus.

Scrambling to get production underway, the workers took apart a ventilator and 3D scanned each of the roughly 300 parts, creating computer simulations of how the device could be assembled efficiently. Ford, which has partnered with a ventilator-maker and GE Healthcare, has been rushing to train workers and obtain the parts to have its first prototype ready early next week.

Ford and General Motors both announced in late March that they would build the medical machines after shutting down car production and sending workers home, a historic redeployment of their factories and workers.

Ford said it aims to produce 1,500 ventilators by the end of the month. GM, which brought its first group of 100 project workers into training this week, said it will start producing 10,000 units per month by as early as mid-May.

The effort is a test of American manufacturing might the likes of which hasn’t been seen in decades. Employees and executives at Ford and GM said they’re working around the clock, driven by a sense of patriotism similar to when the companies were recruited to build equipment and airplanes during World War II.