SYDNEY, Australia — Prime Minister Peter O’Neill of Papua New Guinea resigned on Sunday, as a flood of high-level defections from his governing party led him to step down after almost eight years in power.

Mr. O’Neill told reporters in Port Moresby, the capital, that there was a clear “need for change.”

He said he had handed over leadership of the Pacific nation to Julius Chan, who has served as prime minister twice before, though the opposition party said it would soon form its own government, suggesting the next few days could be defined by uncertainty and shifting alliances.

“By resigning, Mr. O’Neill clears the field for members of his still significant support base to also contest for leadership this week,” said Jonathan Pryke, director of the Pacific Islands program at the Lowy Institute in Australia.

Political instability in the resource-rich and strategically placed country is nothing new; it has often shaken Papua New Guinea since it gained independence in 1975. But Mr. O’Neill’s departure comes at a sensitive moment, with China and the West fighting for influence across the Pacific.