Ranil Wickremesinghe was sworn in as Sri Lanka's new prime minister as the island nation's two major political parties signed an agreement to work together in the new parliament.

His victory in Monday's election thwarted a political comeback bid by the country's former strongman president, Mahinda Rajapaksa, seven months after he lost his presidential re-election bid.

Wickremsinghe, a lawmaker since 1977, has already served three times as prime minister, a position second to the president in Sri Lanka. He was sworn in on Friday before President Maithripala Sirisena.

Wickremesinghe's United National Party won 106 seats, seven short of a majority in the 225-member parliament. But the agreement between the UNP and Sirisena's Sri Lanka Freedom Party will enable Wickremesighe to secure a majority in parliament.