Malaysia's former Prime Minister Mahathir Mohamad has met face-to-face with his one-time sworn enemy Anwar Ibrahim for the first time in 18 years, as the two unite behind a push to oust embattled Prime Minister Najib Razak.

The historic meeting of the two titans of Malaysian politics took place in a courtroom on Monday, where imprisoned Opposition Leader Anwar was mounting a legal challenge to controversial security laws recently introduced by Mr Najib.

Anwar-Mahathir timeline 1981: Dr Mahathir becomes PM of Malaysia

1981: Dr Mahathir becomes PM of Malaysia 1982: Anwar Ibrahim joins UMNO

1982: Anwar Ibrahim joins UMNO 1993: Dr Mahathir appoints Anwar as deputy PM

1993: Dr Mahathir appoints Anwar as deputy PM 1997: Asian financial crisis sends shockwaves through Malaysian economy

1997: Asian financial crisis sends shockwaves through Malaysian economy September 1998: In a dramatic 48 hours, Dr Mahathir introduces currency controls and sacks Anwar as deputy PM and finance minister; Anwar leads criticisms of Dr Mahathir and calls for reform

September 1998: In a dramatic 48 hours, Dr Mahathir introduces currency controls and sacks Anwar as deputy PM and finance minister; Anwar leads criticisms of Dr Mahathir and calls for reform 1998 - 2000: Anwar charged and imprisoned for corruption and sodomy

1998 - 2000: Anwar charged and imprisoned for corruption and sodomy 2003: Dr Mahathir stands down as PM, promises to stay out of politics

2003: Dr Mahathir stands down as PM, promises to stay out of politics 2004: Anwar released from prison after appeal

2004: Anwar released from prison after appeal 2008: Anwar sworn into Parliament, becomes Opposition Leader; He is charged again with sodomy

2008: Anwar sworn into Parliament, becomes Opposition Leader; He is charged again with sodomy 2013: Anwar leads Opposition to close election, beating UMNO in primary vote

2013: Anwar leads Opposition to close election, beating UMNO in primary vote 2014: Court overturns earlier acquittal on sodomy charges, following government appeal

2014: Court overturns earlier acquittal on sodomy charges, following government appeal February 2015: Anwar jailed for five years

February 2015: Anwar jailed for five years 2015: Dr Mahathir joins chorus of people calling for PM Najib to step down following 1MBD crisis

2015: Dr Mahathir joins chorus of people calling for PM Najib to step down following 1MBD crisis 2016: Dr Mahathir quits UMNO and announces plans for new party, with promise to work with Opposition

2016: Dr Mahathir quits UMNO and announces plans for new party, with promise to work with Opposition September 5, 2016: Anwar and Dr Mahathir meet face-to-face for the first time in 18 years

Dr Mahathir quit the ruling United Malays National Organisation (UMNO) in February after becoming increasingly critical of Mr Najib's leadership in the wake of corruption allegations.

Dr Mahathir is leading a new political party, which was officially registered on Thursday and includes several former senior UMNO figures who were sacked after publicly criticising Mr Najib.

"My father always reminds us to forgive," said Nurul Izzah Anwar, daughter of Anwar Ibrahim and Vice-President of the opposition People's Justice Party.

"The fact that my father shook his hand and managed a warm smile symbolises the importance of moving forward to strengthen Malaysia's democracy, instead of focusing on personal suffering".

From protege to prison

Dr Mahathir and Anwar have had a long and tumultuous relationship that has shaped Malaysian politics for decades.

It was Dr Mahathir who convinced Anwar — then a fiery government critic and leader of an Islamic youth movement — to join UMNO in 1982, shortly after he became prime minster.

Under the leader's wing, Anwar rose quickly within the ranks of UMNO, becoming finance minister and then going on to become deputy prime minister in 1993.

Then-deputy PM Anwar (L) greets PM Mahathir Mohamad after the opening of the UMNO general assembly in 1997. ( AFP: Francis Silvan )

However, when the asian financial crisis hit the region in 1997, cracks emerged in the relationship between Dr Mahathir and his anointed successor over Malaysia's economic response to the crisis.

In a dramatic falling out, Dr Mahathir sacked his deputy in September 1998.

Anwar responded to the sacking by leading a series of mass protests calling for Reformasi — or political reform.

Anwar Ibrahim removes a ball of dust from Dr Mahathir's sleeve during a press conference in 1997. ( AFP: Francis Silvan )

Later that month, Anwar was arrested under the controversial Internal Security Act, and when he appeared in court he had a visible black eye, which he said was a result of being bashed in prison.

Anwar was later jailed on charges of corruption and sodomy, which he denied and claimed were politically motivated.

Anwar supporters burn a photo of then-PM Mahathir Mohamad in 1998. ( AFP: Emmanuel Dunan )

After 22 years at the helm of Malaysia, Dr Mahathir stood down in 2003, handing over to his hand-chosen successor Abdullah Ahmad Badawi and promising to stay out of politics.

Anwar was released from prison in 2004 and went on to lead the opposition movement to historic election results in 2008 and 2013.

Last year, he was jailed again on a separate sodomy charge, which he also denied.

Anwar Ibrahim and wife leave their Kuala Lumpur house after his ousting in 1998. ( AFP: Upali Aturugiri )

Dr Mahathir initially supported Mr Najib Razak's ascension to Prime Minister in 2009, but he grew increasingly critical of him in 2015 in the wake of allegations Mr Najib had siphoned money from state-owned investment fund 1Malaysia Development Berhad (1MBD).

In July 2015, the Wall Street Journal reported that $US700 million of funds siphoned from 1MBD had made its way into Mr Najib's private bank account.

Mr Najib vehemently denied any allegations of wrongdoing and said the money was a political donation.

In July, the United States Department of Justice (DOJ) ordered their largest ever seizure of assets, with more than $US1 billion in assets targeted for allegedly being stolen from 1MBD.

Close allies of Mr Najib were listed in the DOJ seizure documents as well as his stepson Riza Aziz and an unnamed 'Malaysian Official 1' who was listed as a 'close relative' of Riza. Mr Najib denies any connection.

Desperate times?

Malaysia's Deputy Prime Minister Zahid Hamidi on Tuesday told reporters the meeting between Dr Mahathir and Anwar was a "desperate action".

"This desperate meeting is seen by the public as an insincere political move," he said.

However, Opposition MP N Surendran, who is acting as Anwar's lawyer and was present during the courtroom meeting, said it was a moving moment.

"No one expected in their life to see these two men burying the hatchet and shaking hands," Mr Surendran said.

Anwar and Dr Mahathir shake hands in court. ( Supplied: Najwan Halimi )

"Dr Mahathir isn't in power anymore, while what happened previously cannot be forgotten, as long as he doesn't go back to his old ways it can't impede going forward with the reform agenda".

Ibrahim Suffian, a political analyst from the independent Merdeka Centre said while the meeting was significant, it was a sign of the compromises Dr Mahathir had been forced to make by working with the opposition.

"In politics there is no friends of foes, only interests. Dr Mahathir has limited options left — he tried to remove Mr Najib internally from within UMNO but this is the only option he has now."

Dr Mahathir quit UMNO in February to form his new political party, which also includes a former deputy prime minister and several other senior government figures who were sacked after criticising Mr Najib.

Anwar had previously managed to lead a tenuous coalition of opposition parties to electoral milestones in 2008 and 2013, despite the often conflicting ideologies of the Chinese-majority and Islamist parties.

Ibrahim said while Dr Mahathir still commanded high levels of support from within UMNO, the challenge would be whether he could re-unite the opposition movement, who have splinted since Anwar's imprisonment.

"Dr Mahathir is well placed to strike a deal [to unite the opposition parties], though it won't be easy," Ibrahim Suffian said.

"If they can unite, Dr Mahathir may be able to shave enough support off UMNO to give the Opposition a real chance of taking power".

Malaysia has not had a change of government since independence from the British in 1957.