He was first elected to the Knesset on Degel HaTorah's list in 1988, and was appointed Deputy Minister of Religious Affairs in
Yitzhak Shamir's government in 1990. For the
1992 elections, the party joined
Agudat Yisrael in forming an alliance called
United Torah Judaism, which won four seats. Although he initially lost his seat, Gafni entered the Knesset in 1994 as part of a rotation agreement between the two factions. A similar arrangement operated after the
1996 elections, with Gafni taking the seat for the first half of the session (i. e., until 1998). Early elections in 1999 meant that Gafni re-appeared in the Knesset sooner than expected. This time, no rotation agreement was in place, so he served his full term, and was re-elected in both 2003 and 2006. When Degel HaTorah split from Agudat Yisrael during the latter stages of the 16th Knesset, Gafni was appointed the party's Parliamentary Group Chairman. In the 18th Knesset, Gafni was the chairman of the Knesset's financial committee. ==Views and opinions==