The government's National Cyber Security Centre said the attack involved the use of "Powershell" malware, but it did not comment on the source of the attack or which government bodies were targeted.
"The NCSC has detected a new Advanced Persistent Threat (APT) that is targeting Saudi Arabia," the agency said in a statement, adding the attack sought to infiltrate computers using email phishing techniques.
Saudi Arabia has come under frequent cyber attacks, including "Shamoon", the aggressive disc-wiping malware employed in attacks against the Saudi energy sector in 2012.
Saudi Aramco, the world's biggest oil company, was among the firms hit by Shamoon, in what is believed to be the country's worst cyber attack yet.
US intelligence officials at the time said they suspected a link to the kingdom's regional rival Iran.