"As the president of UMNO and the chairman of Barisan Nasional, I made the decision that I am stepping down as president of UMNO and chairman of Barisan Nasional with immediate effect," Najib told a press conference at the UMNO headquarter in Kuala Lumpur.
The resignation is to take up the responsibility for the defeat in the general elections, he said.
UMNO has led a multi-party coalition to govern Malaysia since the country's independence in 1957 until the election defeat on Wednesday.
Najib, who became prime minister in 2009, was barred from leaving the country by the immigration department as he was about to leave Malaysia "to take a break" earlier Saturday.
The new government led by Mahathir Mohamad has vowed to reopen investigation into the scandal of state investment fund 1MDB. Mahathir has said that if Najib were found to do something wrong, "he will have to face the consequences."