SEOUL, South Korea — Military investigators raided South Korea’s Cyberwarfare Command on Tuesday after four of its officials were found to have posted political messages online last year, in what opposition lawmakers have called a smear campaign against President Park Geun-hye’s opponents before her election in December.

Ms. Park defeated her main opposition rival, Moon Jae-in, by roughly a million votes in the election and took office in February. But in a snowballing scandal, prosecutors have since said that agents of the National Intelligence Service posted thousands of anonymous Internet messages during the presidential campaign supporting Ms. Park and her governing Saenuri Party or berating government critics, including opposition presidential candidates, as supporters of North Korea.

Last week, opposition lawmakers alleged in the National Assembly that the military’s secretive Cyberwarfare Command had carried out a similar online campaign, separately or in coordination with the spy agency, to help sway public opinion in favor of Ms. Park before the Dec. 19 election.

On Tuesday, the Defense Ministry confirmed that four cyberwarfare officials had posted political messages. It quoted them as saying they had acted on their own. Still, “the ministry will investigate whether there was command-level involvement,” the ministry’s spokesman, Kim Min-seok, said, explaining the raid on the command headquarters.