To begin, note that attempting to use DSolve on both equations simultaneously
DSolve[{D[f[x, y], x] == (g'[x] f[x, y] - a1)/(1 - g[x]),
D[f[x, y], y] == a2/(1 - g[x])}, f[x, y], {x, y}]
returns unevaluated. So, use it to solve each separately.
DSolve[D[f[x, y], y] == a2/(1 - g[x]), f[x, y], {x, y},
GeneratedParameters -> B] // First
(* {f[x, y] -> -((a2 y)/(-1 + g[x])) + B[1][x]} *)
DSolve[D[f[x, y], x] == (g'[x] f[x, y] - a1)/(1 - g[x]), f[x, y], {x, y},
GeneratedParameters -> A] // First
(* {f[x, y] -> (a1 x)/(-1 + g[x]) + A[1][y]/(-1 + g[x])} *)
Of course, these solutions must be equal. Therefore, by inspection, the solution is
s = f[x, y] -> (a1 x)/(-1 + g[x]) - (a2 y)/(-1 + g[x])
To verify this result, substitute s back into the two equations.
(Unevaluated[D[f[x, y], x] == (g'[x] f[x, y] - a1)/(1 - g[x])] /. s) // Simplify
(* True *)
(Unevaluated[D[f[x, y], y] == a2/(1 - g[x])] /. s) // Simplify
(* True *)
DSolveorNDSolve. Please edit your question to provide your equations in Mathematica format and to provide an example forg[x]. – bbgodfrey Jan 05 '16 at 16:11