The country's King Al Sultan Abdullah Sultan Ahmad Shah made the announcement five days after the parliamentary election left no party with a majority to form a government on its own.
Opposition leader Anwar Ibrahim has been appointed as Malaysia's 10th prime minister, ending days of political impasse in the Southeast Asian country.
The country's King Al Sultan Abdullah Sultan Ahmad Shah made the announcement on Thursday, five days after the parliamentary election, which left no party with a majority to form a government on its own.
Anwar was sworn in by the king at 0900 GMT. His wife, Was Azizah Wan Ismail accompanied him.
In a statement after taking his oath, Anwar vowed to carry out his position "with full humility and responsibility.
"I will take on this heavy task based on the will and conscience of the people and the country."
Anwar's appointment is the third time the king has chosen a prime minister in just over two years - though it's the first time this has happened following a general election.
In the announcement, the king also urged all members of parliament "to reach out to each other" and "show solidarity...for the sake of the future of our beloved country."
He called on all Malaysians "to keep calm and pray for the country", adding that the rulers from all the country's nine states support his position "for the formation of a stable government as soon as possible."
Earlier on Thursday, the king held a meeting with the rulers from all states to consult them about his decision to name a new prime minister.
The king also held a separate meeting on Wednesday with the newly-elected parliament members from UMNO, the once-dominant party, to ask them who they back as prime minister.
For days, the country was left guessing on who will the king appoint after Anwar and his rival former prime minister Muhyiddin Yassin both claimed that they have the necessary 112 votes in the 222-seat parliament to become the country's next leader.
At the weekend election, Anwar's Pakatan Harapan (Alliance of Hope) coalition won the most number of seats at 82 while Muhyiddin's Perikatan Nasional (National Alliance) grouping grabbed 73, but both missed the simple majority of 112.
UMNO suffered its worst defeat on Saturday, but still managed to hold on to 30 seats, making the bloc a king-maker in a hung parliament.
Anwar's coalition had initially entered negotiations with UMNO and its Barisan Nasional coalition on Monday.
But talks broke down and caretaker Prime Minister Ismail Sabri, later said that his coalition has decided to be in the opposition.
Later on Thursday, UMNO backed off from that announcement saying it has agreed to be part of a unity government lead by Anwar.
According to a Straits Times report, UMNO's Mohamad Hasan will be named as Anwar's deputy prime minister.
Anwar also won the support of party blocs from Sabah and Sarawak, solidifying his unity government.