The answer with most "what came first?" questions is: *they both evolved together.*

First, it's important to understand that sexual reproduction can occur without differentiation between males and females.

Examples:

* Amoebas will congregate into a little stalk (when food is scarce) and release spores in the air that go out and fertilize other spores and start a new colony of amoebas. That is sexual reproduction, but neither one is the 'male' or the 'female'.

* Most flowering plants reproduce by releasing pollen in the air (or on pollinating insects like bees) that travel to other flowers and fertilize them. Again, since all flowers have both male (pollen producing) and female (pollen receiving) parts, the plant is neither male nor female.

* Many animals are 'hermaphrodites', having both male and female parts ... so every individual is both male and female.

* Other animals actually start out undifferentiated, but *become* male or female at some point during development based on what they are fed, the temperature during development, what hormones they are exposed to, or what other sexes they encounter as adults.

So the answer to your question is that sexual reproduction evolved first ... without differentiation into 'male' and 'female'.

Only later did the differentiation between 'males' and 'females' evolve, so that individuals did not have to have both kinds of sex organs. So as some individuals slowly became more and more specialized in producing male gametes (pollen or sperm cells) ... other individuals slowly became more and more specialized in producing female gametes (ova or egg cells).

So 'male' and 'female' evolved *together*, and there was never a problem of one having to survive without the other.