Dozens of auto repair shops and service stations in New York City, Long Island and Westchester County faked the results of emissions tests, giving nearly 21,000 cars and light trucks passing grades, state environmental officials said Thursday.

Officials with the State Department of Environmental Conservation said they had issued citations to 40 of about 3,500 inspection sites in the region for granting inspection certificates for vehicles that were not tested.

To pass the annual state emissions inspection, a car or truck is connected to a machine that checks the vehicle’s computerized emissions control system and sends the information to the State Department of Motor Vehicles. But the repair shops and service stations that were cited attached the inspection equipment to an electronic device that simulated the test.

“New York State does this program because we want clean air and because we need to comply with the federal Clean Air Act,” said Steven E. Flint, a director with the Environmental Conservation Department’s air resources division. “When people start cheating the system,” Mr. Flint said, “it deprives air quality of that benefit.”