Police officers accused of criminal wrongdoing cannot escape scrutiny by Ontario's Special Investigations Unit simply by resigning or retiring before a complaint is made, the province's top court ruled Monday.

The ruling also affirmed the right of the agency to investigate alleged police crimes that occurred before it was set up in 1990.

In the case at hand, a woman complained in June 2010 that a police officer from Peel Region had sexually assaulted her during the early 1980s. She also alleged a second officer either witnessed or knew of the assaults.

The SIU, whose mandate is to probe serious injuries and deaths in which police may have acted criminally, began investigating.

However, Peel regional police argued the SIU had no jurisdiction because both officers had retired by the time the woman complained.

Peel also argued the SIU had no right to investigate because the alleged wrongdoing occurred before its formation.

As a result, the police force insisted it should carry out the investigation, not the SIU.

The two sides ended up in Ontario Superior Court, which sided with the SIU.

In the earlier ruling, the lower court justice said the wording of the Police Services Act did give the SIU jurisdiction to probe the conduct of officers, even if they had retired or resigned before the complaint was made.

The act's reference to police officers must be interpreted as "referring to police officers at the time of the alleged misconduct," the court found.

While legislation cannot normally be applied retroactively, the lower court justice also decided the act did empower the SIU to look into alleged offences committed prior to its creation.

Peel police took the case to the Ontario Court of Appeal, which agreed with the lower court on both counts.

"An ongoing SIU criminal investigation could be ground to a halt by the simple act of the resignation or retirement or the discharge of the police officer whose alleged conduct is the subject of the investigation," the Appeal Court stated.

"Bluntly put, this would mean that the SIU's investigative jurisdiction would be subject to the unilateral and potentially capricious control of the affected police force and the suspect officer."

The court noted the aim of the legislation is to provide a public benefit, namely the independent oversight of police conduct without causing any detriment to the subject officers.

In a statement, SIU Director Ian Scott said the decision "makes it clear that police officers cannot escape the jurisdiction of the SIU by resigning or retiring."

Scott said the agency would restart its probe into the sexual assault allegations if Peel does not try to take the case to the Supreme Court of Canada.

On Monday afternoon, Peel regional police released a statement saying the force welcomed the decision from the court.

"We welcome the decision as it now provides clarity to all Ontario police services regarding the authority and mandate of the SIU with respect to allegations of historic criminal conduct.  I will be recommending to the Police Services Board that this ruling not be appealed to the Supreme Court of Canada," Acting Chief Paul Tetzlaff said in a statement.

The Appeal Court also awarded the SIU $11,500 in costs.

With files from CBC News