Describing his victory as a vote of confidence for the Pakatan Harapan (PH) government and its reform agenda, he said the result also showed the PH's ability to garner support from all of the country's ethnic groups.
Mr Anwar, the de facto leader of the PH coalition, won the by-election for the parliamentary seat in a seven-way contest with 72 per cent of the vote.
He also sealed his victory with a majority of 23,560 votes, exceeding that of previous MP Danyal Balagopal Abdullah of his Parti Keadilan Rakyat (PKR), who won the seat in Malaysia's 14th General Election in May by a margin of 17,710 votes.
"Now we are able to capture the confidence of all races, in areas where the Malays were the majority, where the Chinese were the majority and also where the Indians were the majority, not forgetting the Orang Asli population," Mr Anwar said at a press conference after being declared the winner.
"In two state seats under the Port Dickson parliamentary constituency (Bagan Pinang and Linggi) that we previously lost in GE14, we have now won them with style, with big majorities," he was quoted as saying by Bernama.
Saturday's by-election was called after Mr Danyal vacated the seat to allow Mr Anwar to return to politics. Mr Anwar, who was in prison during the May general election, received a royal pardon after the PH took office.
The victory paves the way for the 71-year-old to take over from Tun Dr Mahathir Mohamad as Malaysia's eighth prime minister - a move that had been agreed upon by the four component parties of the PH before the election.
Mr Anwar, who is also PKR president-elect, said that votes from Malaysian Armed Forces personnel which had previously been less favourable to PH saw a surge of almost 122 per cent from the last general election.
"Of course, I would like to return my appreciation to Port Dickson, a new parliamentary constituency for me, and I am very impressed by this support. I can only promise that we will do our best for Port Dickson," he said.
Mr Anwar also contacted Dr Mahathir with the good news. "The Prime Minister is proud of the outcome," he said. He also thanked the parties in the PH coalition for help given in his election campaign.
Along with the PKR, Dr Mahathir's Parti Pribumi Bersatu Malaysia, the Democratic Action Party and the Parti Amanah Negara are also members of the PH pact.
Mr Anwar said the PH's spirit of consensus had brought a strong mandate for him in the by-election.
He said he would be sworn in as an MP today and pledged to bring about changes in the institution with other MPs. "I will continue to serve as a Member of Parliament and assist other friends, especially senior Members of Parliament such as Lim Kit Siang, to formulate reforms and hold forums, as well as discussions with ministers from time to time," he said.