BANGKOK — Malaysia’s attorney general said on Tuesday that he had closed an investigation into transfers of hundreds of millions of dollars into Prime Minister Najib Razak’s personal bank accounts because no laws had been broken.

The decision, greeted with outrage and cynicism by the opposition, appears to prolong the embattled premiership of Mr. Najib, who has struggled to explain why nearly $700 million had been transferred to him.

Attorney General Mohamed Apandi Ali told reporters at a hastily convened news conference on Tuesday in the country’s administrative capital, Putrajaya, that he had ordered the anticorruption commission to close the investigation into the money that Mr. Najib received.

Mr. Apandi, who was appointed by the prime minister last year after the previous attorney general abruptly left office, said the largest amount, $681 million, “was a personal donation” from the Saudi royal family.