The vehicle carrying four ABB Energy engineers — three Germans and a Czech — had been travelling between Ajdabiya and Zwitinah, where they were working on a power station control system.
The German was hit twice, in the chest and foot, and the driver, despite receiving a head wound, managed to manoeuvre the car to safety, the security official in Ajdabiya said.
Both of the wounded men were treated at Ajdabiya hospital before being transferred to Libya's second city Benghazi, 130 kilometres (80 miles) to the east, the official added.
Citing the other engineers, he said the masked gunmen had been on board two pick-up trucks painted in military colours.
Eastern Libya, where the uprising against dictator Muammar Gaddafi erupted in 2011, has seen several attacks against the authorities and Western interests, which have been blamed on Islamists.
Among them was a deadly assault on the US consulate in Benghazi on last year, in which Ambassador Chris Stevens and three other Americans were killed.
In 2008, a Swiss ABB manager was arrested along with another Swiss businessman in Libya under the Gaddafi regime.
The pair were eventually released in 2010 but only after then Swiss President Hans-Rudolf Merz issued an apology to Libya after Gaddafi's son Hannibal and his wife were arrested in Geneva for allegedly beating their two servants in a hotel.
The couple were allowed to return to Libya and charges were dropped.