Ireland’s ruling Fine Gael party and its longtime rival Fianna Fáil have moved closer to forming an unprecedented coalition government.

Leo Varadkar, the taoiseach and Fine Gael leader, and Micheál Martin, the Fianna Fáil leader, agreed on Tuesday to seek a “full and equal partnership” for five years, during which they would rotate the position of taoiseach. The pair will brief their parties on the details on Wednesday.

The deal followed on-off talks after a general election in February, which punished both centrist parties and left a hung parliament, with leftwing parties unable to muster a majority.

Varadkar and Martin must sell the deal to their parties and woo an additional party, or group of independent TDs (MPs), before forming an administration, a process that could take weeks.

The election marked a revolt against the political establishment but parliamentary arithmetic and the coronavirus pandemic paved the way to a grand alliance between two rivals that have dominated Ireland for almost a century.

Sinn Féin won more votes than any other party in the election – a breakthrough that shocked even its own leaders. But it could not form a government without Fine Gael or Fianna Fáil, which rejected the republican party, citing its links to the IRA.

Sinn Féin’s leader, Mary Lou McDonald, disclosed on Tuesday she had tested positive for coronavirus but had recovered and was no longer deemed infectious.

Fine Gael and Fianna Fáil have a combined 72 seats, eight short of a majority in the 160-seat Dáil Éireann. They have eyed the Greens, Labour and other small leftwing parties as potential partners but there is no guarantee any will enter a government that will face economic dislocation and tough choices amid the coronavirus pandemic.

Varadkar and Martin agreed to form a majority government of three or more parties or groups that will last five years with “full and equal partnership between FG and FF at its centre”, Martin Heydon, Fine Gael’s parliamentary party chairman, told members.

Voters punished Varadkar and his party for a housing and healthcare crisis but as a caretaker the taoiseach has won plaudits for his handling of coronavirus.

Eoin Ó Broin, Sinn Fein’s housing spokesman, predicted Fine Gael and Fianna Fáil would struggle to find another partner. “It is shocking, even by Fine Gael standards, that housing doesn’t feature in their government policy test list.”