President Yoon Suk Yeol declared martial law on Tuesday night in a move that stunned South Koreans and triggered a short-lived attempt by troops to enter parliament.