Iran’s military announced early Saturday that it had accidentally shot down a Ukrainian passenger jet, blaming human error because of what it called the plane’s sharp, unexpected turn toward a sensitive military base.

After days of tension since the jet crashed near Tehran on Wednesday, the same day that Iranian missiles struck American bases in Iraq, the admission was a stunning reversal. Iran initially maintained that mechanical issues had brought the Boeing airliner down, killing all 176 people aboard.

“The Islamic Republic of Iran deeply regrets this disastrous mistake,” President Hassan Rouhani said on Twitter soon after the military released its statement. He offered condolences to the victims’ families and said investigations were underway. The military said the person responsible would face legal consequences.