Rajoy lost a parliamentary confidence vote triggered by a long-running corruption trial involving members of his center-right party.
Separatists declared victory in Thursday's regional election.
Catalonia declared independence on Friday. Minutes later, Spain imposed direct rule.
Spain is already fighting back.
Mariano Rajoy said his government had taken this unprecedented decision to restore the law.
If Spain's prime minister invokes Article 155 of the 1978 constitution, it would not be fully effective until at least early next week.
It was not a historic session, but rather an eccentric event.
The prime minister's move could deepen the confrontation between Madrid and Catalonia.
What Mas, Puigdemont, Junqueras and Romeva hadn’t achieved for years, the government did in just 24 hours.