William Petersen had a scary situation while on the clock this week -- he had to be taken by ambulance to the hospital after falling ill on set of his most popular show.
The longtime 'CSI' star's rep tells TMZ ... Petersen was working on set Friday in L.A. for "CSI: Las Vegas" when, at some point, he started feeling terrible ... and told the director that he needed a break.
It became clear he might've needed more than just a rest -- because we're told an ambulance was called on his behalf, and Bill was taken to a nearby facility. The rep says it was mostly done out of an abundance of caution, but it was clearly serious enough to call.
As to what led to the health scare ... WP's rep tells us his guy has been working nonstop long days for the past 12 weeks -- so this may have been a case of overexertion or exhaustion.
In any case, we're told Bill's now out of the hospital and doing better. Case closed ...