The early morning collision caused a fire at the St Andrews Memorial Hospital in Largo Road.
Police Scotland said the Audi car was found ablaze and "embedded" in the wall of the building at around 02:30.
Officers traced a 27-year-old man to a nearby property and he was taken into custody in relation to road traffic offences.
They said the incident could have had "much more serious consequences".
No-one was hurt but the building suffered "significant damage", according to NHS Fife.
The health board said a GP practice which operates from the building had to close but the hospital, which treats mainly older patients, was operating as normal.
Sgt Pat Turner, of Police Scotland, said:  "It was extremely fortunate that the part of the building with which the vehicle collided was not being used at that time.
"But this incident had the potential for much more serious consequences.
"This was undoubtedly a frightening experience for hospital residents but staff and emergency services initiated established protocols which resulted in the safe evacuation of all patients and staff."
A spokesman for NHS Fife warned that the accident was likely to cause further disruption to GP appointments on Friday.
He said: "Whilst we are working hard to mitigate the impact of this incident, today's disruption is expected to continue into tomorrow and we will continue efforts to contact any outpatients who may be affected.
"Importantly, if there is a need for urgent GP assessment, please present to the minor injuries unit or contact NHS 24. Inpatient care remains unaffected and wards should be contacted in the usual manner.
"The car involved in the collision will remain on site ahead of a structural assessment tomorrow and security services will be present overnight. This situation continues to be under regular review and further information will be made available in due course."
Fifteen patients were evacuated from a hospital in St Andrews after a car crashed into a wall of the building.