BENGHAZI, Libya — In less than three weeks, an inchoate opposition in Libya, one of the world’s most isolated countries, has cobbled together the semblance of a transitional government, fielded a ragtag rebel army and portrayed itself to the West and Libyans as an alternative to Col. Muammar el-Qaddafi’s four decades of freakish rule.

But events this week have tested the viability of an opposition that has yet to coalesce, even as it solicits help from abroad to topple Colonel Qaddafi.

Rebels were dealt military setbacks in Zawiyah and Ras Lanuf on Tuesday, part of a strengthening government counteroffensive.

Meanwhile, the opposition council’s leaders contradicted one another publicly. The opposition’s calls for foreign aid have amplified divisions over intervention. And provisional leaders warn that a humanitarian crisis may loom as people’s needs overwhelm fledgling local governments.