Varma and Balyawi defeated Independents Anil Sharma and Sabir Ali, Assembly Secretary Hareram Mukhiya told reporters here.
Varma secured 122 votes against Anil Sharma's 108, while for the other seat, JD(U)'s Gulam Rasool Balyawi bagged 123 votes against Sabir Ali's 107, he said.
There was cross-voting by members from JD(U), RJD and Congress.
JD(U) candidates should have got 143 votes on the basis of strength of 116 MLAs of the party, besides 20 of RJD, 4 of Congress, 2 Independents and 1 CPI.
Speaker Udai Narayan Choudhary from JD(U) did not vote.
RJD MLA Kedar Singh did not vote as he was absconding in a some criminal case.
JD(U) overcame cross-voting by party MLAs in favour of BJP-backed Independents
The two Independents, real estate baron Anil Sharma and Sabir Ali, bagged 17 and 16 votes of JD(U) dissidents, because of cross voting by two members each from RJD and Congress.
"Nitish had to crawl to Lalu Prasad for victory of two JD(U) candidates," Sabir Ali, who was expelled from JD(U) on the eve of the Lok Sabha elections, told reporters.
JD(U) state President Basistha Narayan Singh congratulated the winners and thanked Lalu Prasad, Congress, CPI and Independents for ensuring the victory.
On cross-voting by JD(U) legislators, Singh said party election observers would submit a report after which action would be taken against those going against party.
Senior BJP leader Sushil Kumar Modi said, "Nitish Kumar has lost it politically despite winning the bypoll, for which he had to align with RJD supremo Lalu Prasad, who symbolised ‘jungle raj' in Bihar."
The victory of JD(U) candidates came as a moral booster for Nitish Kumar's party which received severe drubbing in the Lok Sabha elections winning just 2 of the 40 seats.
The term of the three seats for which the elections were held would be till July 2016. One seat was won by JD(U) President Sharad Yadav unopposed.
The three seats were vacated by Ramvilas Paswan, Rajiv Pratap Rudy and Ramkripal Yadav after their victory in the Lok Sabha elections.
Mukhiya said that the election was conducted under guidelines of the Election Commission of India.
State Chief Electoral Officer Ajay Naik and his Madhya Pradesh counterpart Jaydeep Govind, who was special observer, strictly monitored the bypoll, Mukhiya said.
As per direction of the EC, no party had issued whip to its members which helped members of political parties indulge in cross-voting.
A total of 230 MLAs out of an effective strength of 232 in the Assembly took part in the voting.