A by-election loss could jolt NSW opposition leader Mark Speakman's grip on the Liberal leadership after voters in the state's south backed a Labor candidate to replace a disgraced MP.
Voters in the electorate of Kiama chose a new representative to state parliament after former MP Gareth Ward was forced to resign after being convicted of sexual and indecent assault in July.
It is the first time in three decades a seat in a by-election has gone to the government.
Labor candidate Katelin McInerney's victory was the first major electoral test for the Minns government.
"I am humbled and honoured to have been elected as your MP," she said.
Premier Chris Minns said the result was a humbling success.
"My government views this result as an invitation to work even harder for the entire state,