The party won almost 44% of votes, which translated into 235 seats in the 460-member Sejm, the same number it won in 2015. However, Law and Justice leader Jaroslaw Kaczynski had counted on claiming enough seats to amend the Constitution.
Law and Justice also lost control of the 100-seat Senate. Opposition parties won 51 seats and therefore will be able to prevent the ruling party from rushing through laws without consulting them, as it often did in the last four years.
Kaczynski nonetheless described the support from voters as a clear go-ahead for the party to continue policies that have affected fundamental parts of Polish life, including a judicial overhaul the European Union condemned as a threat to the rule of law.
The main opposition force, the Civic Coalition, a centrist alliance built around the Civic Platform party, once led by EU leader Donald Tusk, was running second with over 27% support and 134 seats in the lower house.
Turnout was at a record high of almost 62%, a sign of how important voters considered Sunday's election. Law and Justice, which has governed Poland since 2015, is popular both for its social conservatism and generous social spending, including a program that gives families a monthly stipend of 500 zlotys ($125) for each child. During the campaign, the party highlighted the social programs and vowed to defend traditional Catholic values.
Despite winning the right to keep governing, Law and Justice leaders were subdued. The election results left them short of the two-thirds Sejm majority needed to amend the Constitution, which was a goal as they seek to reshape Poland into a modern state rooted in a conservative Roman Catholic worldview rejecting abortion and gay rights.
The Senate is less powerful than the lower house but can delay or amend legislation the Sejm already passed. Kaczynski, the powerful party leader, said there was "room for compromise and cooperation in the Senate" after Law and Justice lost its majority there.
Political analyst Radoslaw Markowski said that given the huge effort the party and Kaczynski personally put into campaigning, the result was "so-so." Some unpopular ruling party officials failed to win seats at all, including Stanislaw Piotrowicz, a communist-era state prosecutor who was a key architect in controversial laws that reshaped Poland's judicial system.
In other results, a left-wing coalition build around the Democratic Left Alliance came in third with over 12% support and 49 seats, which brought the left back into parliament after having no representation there over the past four years.
The conservative agrarian Polish People's Party, in alliance with an anti-establishment party led by a rock star, Kukiz 15, got nearly 9% and 30 seats in Sunday's vote. Confederation, a new far-right group that is openly anti-Semitic and homophobic, was to enter parliament after winning almost 7% and 11 seats.
The Organization for Security and Cooperation in Europe, which monitored the campaign, said "clear media bias" and intolerant rhetoric detracted from an otherwise well-run election. The right-wing ruling party used public media to promote its successes and to cast a poor light on the opposition. Public media, in many cases, also depicted the LGBT rights movement as a dire threat to Poland, echoing the rhetoric of the ruling party, Confederation and the Catholic Church.
Monika Scislowska contributed to this report.