Five years later the civilian government was replaced by a military regime that soon declared a socialist republic .