LISBON—Prime Minister Pedro Passos Coelho, who oversaw years of unpopular austerity measures that averted Portugal's bankruptcy, finished far ahead of his Socialist rival in elections on Sunday, but his center-right coalition lost its majority in Parliament.