CAIRO — When a new bout of fighting between rival militias engulfed the Libyan capital in recent days, badly shaking the fragile United Nations-backed government, some combatants picked up rifles and rocket launchers and headed into the streets.

Others logged on to Facebook.

As rockets rained on parts of Tripoli, hitting a hotel popular with foreigners and forcing the airport to close, and 400 prisoners escaped from a jail, a parallel battle unfolded online. On their Facebook pages, rival groups issued boasts, taunts and chilling threats — one vowing to “purify” Libya of its opponents.

Some “keyboard warriors,” as Facebook partisans are known in Libya, posted fake news or hateful comments. Others offered battlefield guidance. On one discussion page on Thursday, a user posted maps and coordinates to help target her side’s bombs at a rival’s air base.

“From the traffic light at Wadi al Rabi, it is exactly 18 kilometers to the runway, which means it can be targeted by a 130 mm artillery,” the user, who went by the handle Narjis Ly, wrote on Facebook. “The coordinates are attached in the photo below.”