Canada will introduce new anti-terror laws that will make it a crime to promote terrorism against Canadians online.

The laws will also allow anyone suspected of being involved in a terror plot to be detained without charge for up to seven days, and empower Canada's spy agency to thwart attacks directly.

A senior government official provided details to The Associated Press on condition of anonymity because they were not authorized to speak ahead of Friday's announcement.

Work on the law began in October after a gunman killed a soldier at Canada's national war memorial and then stormed Parliament. The attack in Ottawa came two days after a man, said to be inspired by the Islamic State group, ran over two soldiers in a parking lot in Quebec, killing one and injuring the other before being shot to death.