By Veronica Stracqualursi, CNN

A Kentucky high school teacher on Tuesday ousted an incumbent state lawmaker who had a role in passing a controversial pension bill this year that sparked outrage from teachers across the state.

Republican voters chose Travis Brenda, a high school math teacher, over House Majority Floor Leader Jonathan Shell, who was first elected in 2012.

Brenda bested Shell by a narrow margin of 123 votes In Tuesday’s Republican primary for House District 71st, according to unofficial results posted to the Kentucky State Board of Elections.

This past spring, Kentucky teachers held rallies at the state Capitol for more funding and to oppose a controversial pension bill, Senate Bill 151, which, among other initiatives, prevents changes to annual cost-of-living adjustments and limits the number of sick days teachers can put toward their retirement.

Shell had helped turn SB 151, which had been about sewage services, into a pension overhaul and voted in support of the bill. The bill was quickly passed in the House and the Senate without allowing the public to read it, and then sent to GOP Gov. Matt Bevin to sign the bill on April 11.

During the campaign, Brenda used his experience as a teacher to make the point that he’s not a politician and he understands the importance of funding education. On Twitter, Brenda was critical of the pension bill and posted pictures from the April 2 teacher protest at the state Capitol.

Shell confirmed to CNN he called Brenda Tuesday night to congratulate him. Shell, once considered a rising star in Kentucky Republican politics, said he was grateful for the six years he served and now looks forward to spending more time with his wife and kids.

Brenda will go on to face Democratic candidate Mary Renfro in November’s general election.