Likud emerged as the largest party, but after Mr Netanyahu was again unable to form a government, the task passed to Mr Lapid, whose party came second.
Opposition to Mr Netanyahu staying in power had grown, not just among the left and centre but also among right-wing parties that are ordinarily ideologically aligned to Likud, including Yamina.
Although Yamina came joint fifth in the election with only seven seats, its support was critical. After weeks of negotiations, Mr Lapid brought Yamina on board as part of a constellation of parties whose only common goal was to remove Mr Netanyahu from office.
The agreement involving eight factions with the 61 seats required for a majority was signed on 2 June, just half an hour before a deadline was due to expire, effectively sealing Mr Netanyahu's fate.
What will the new government be like?
In appearance, Mr Bennett's government will be unlike any which has preceded it in Israel's 73-year history.
The alliance contains parties which have vast ideological differences, and perhaps most significantly includes the first independent Arab party to be part of a potential ruling coalition, Raam. It also has a record number of nine female ministers.
The inclusion of Raam and left-wing non-Arab Israeli parties means there could be friction on issues such as Israeli policies towards Palestinians - Yamina and another right-wing party, New Hope, are staunch supporters of Jewish settlement in the Israeli-occupied West Bank, for instance.
There could also be difficulties over social policies - while some parties want to advance gay rights, such as recognising same-sex marriages, Raam, an Islamist party, is against this.
In addition, some parties want to relax religious restrictions more extensively than Yamina - a national-religious party - will likely allow.
Mr Bennett has indicated his government would focus on areas where agreement was possible, like economic issues or the coronavirus pandemic, while avoiding more contentious matters.
"Nobody will have to give up their ideology," he recently said, "but all will have to postpone the realisation of some of their dreams... We'll focus on what can be achieved, rather than arguing about what cannot."