People danced and sang in the streets with vuvuzelas, national flags in their hands and clappers.
Ibrahim, who voted for the Alliance for Change, told the BBC that “growing public discontent” was the main reason for the ruling party’s defeat.
The cost of living crisis has been a major concern for many Mauritians, along with growing concerns about governance and corruption.
During the election campaign, both parties promised to improve the lives of people on the islands.
Ramgulam, whose father was a liberation hero and has already served as prime minister twice, said he would increase pensions, introduce free transport and internet and reduce fuel costs.
Former Mauritian foreign minister and member of the opposition coalition, Arwin Boullel, told the BBC’s Newsday program that the election was a “victory for the people”.
Voter turnout was about 80%, according to the election commission.
Citizens came to the polls to elect deputies who will receive 62 seats in the parliament for the next five years.
In addition, up to eight “best performer” seats are allocated to ensure fair ethnic representation in parliament.
Voting takes place after a historical agreement in which Great Britain relinquished sovereignty over the Chagos Islands to Mauritius.