How do we find a competitive equilibrium price when 2 firms operate with different marginal costs? Consider a homogenous goods market with the demand
function Q = 30 − P, where Q and P denote quantity and price respectively.
There are two firms playing a price game in the following manner: firm 1
quotes a price and then firm 2 chooses a price. When they charge the same
price they share the market equally and otherwise the market demand goes
to the firm charging lower price. Firm 1 has a capacity constraint at the
output level 5 units such that upto five units the marginal cost of production
is Rs 3 per unit of output, however beyond 5 units it cannot produce any
output. Firm 2 does not have any capacity constraint, it can produce any
amount with the marginal cost Rs 6. What would be the equilibrium price
in the market?

I'm confused, I think we have to put demand=supply firstly, then if the equilibrium price is 6 (the answer), firm 1 will produce 5 goods but firm 2 has no incentive to produce anything. Will the price not be a little greater than 6?
Ignoring the previously mentioned possibility that the problem may be written incorrectly: The concept of "residual demand" will be helpful here. 

As with any sequential game, it's good to work backwards. From the perspective of firm 2, firm 1 has quoted some price $p_1$, and firm 2 has an opportunity to respond.

Firm 2 knows that if it sets $p_2&lt;p_1$, it will take the whole market, and will face the whole demand curve $Q = 30-p_2$. It can choose the profit-maximizing $p_2$, as long as $p_2&lt;p_1$.

Similarly, if it sets $p_2=p_1$, it will share the market.

Finally, if it sets $p_2 &gt; p_1$, it will face the residual demand left over after firm 1 makes its sales. Assuming that $p_1\leq 25$, firm 1 will sell its five units and then not be able to sell any more. The demand left over for firm 2 to sell to after firm 1 makes its sales will then be $q_2=30-p_2-5$, or $q_2=25-p_2$. Firm 2 can choose its profit-maximizing price given this demand curve.

In each of these cases above, Firm 2 is selecting the profit-maximizing quantity by first setting up profit:

$$\Pi_2 = p_2q_2 - 6q_2 = (p_2-6)q_2$$

Plug in the appropriate $q_2$ using the demand functions determined above, then take the derivative with respect to $p_2$ and set the derivative equal to 0, solve for $p_2$. In each case you're constrained by what $p_2$ can be. If you're working with the $Q=30-p_2$ demand function (which you only get if $p_2&lt;p_1$), then if profit-maximizing price is $p_2&gt;p_1$, then you'll actually want to set $p_2$ just a hair underneath $p_1$ (you can just call it $p_2=p_1$ for simplicity). 

Now you've got the optimal price for Firm 2 to pick given that it's decided to go for $p_2&lt;p_1$, $p_2=p_1$, or $p_2&gt;p_1$. To figure out which of those three it wants, you'll want to calculate Firm 2's profit under each of those scenarios. These profits should be dependent on $p_1$, since $p_1$ determines the boundaries of what $p_2$ can be while still satisfying $p_2&lt;p_1$, $p_2=p_1$, or $p_2&gt;p_1$.

So now Firm 1 knows how Firm 2 will respond to whatever $p_1$ is. And so Firm 1 will set $p_1$ in a way that maximizes Firm 1's profit. This step is a bit easier, since Firm 1 makes nothing under $p_2&lt;p_1$, so it's unlikely that Firm 1 will want to set $p_1$ so that Firm 2 picks $p_2&lt;p_1$.

To make this a bit more clear, let's do an example for Firm 2 making their decision.

Let's say Firm 1 had picked $p_1=10$.

If Firm 2 sets $p_2&lt;p_1$, it is dealing with the demand function $$q_2 = 30-p_2$$. So we set up profit

$$\Pi_2 = (p_2-6)(30-p_2)$$
$$\frac{\partial \Pi_2}{\partial p_2} = 36 - 2p_2 = 0 \Rightarrow p_2=18$$

which is above $p_1=10$. Since profit is strictly increasing in $p_2$ for $p_2&lt;10$, firm 2 will maximize its profit while holding $p_2&lt;p_1$ by setting $p_2=10$ (a hair below 10, really, but let's just say 10). The profit from doing so is

$$\Pi_2 = (10-6)(30-10) = 80$$

And, of course, Firm 1 sells nothing and makes a profit of 0. Now if Firm 2 sets $p_2&gt;p_1$, it's dealing with the demand function

$$q_2 = 25 - p_2$$

and wants to maximize profit

$$\Pi_2 = (p_2-6)(25-p_2)$$
$$\frac{\partial \Pi_2}{\partial p_2} = 31 - 2p_2 = 0 \Rightarrow p_2=15.5$$

which is above $p_1=10$, satisfying $p_2&gt;p_1$. This price leads to the profit

$$\Pi_2 = (15.5-6)(25-15.5)=90.25$$

In this case, Firm 1 sells their five units and makes a profit of $(10-3)5=35$. 

You will also want to check the $p_2=p_1$ case once it's clear what that actually leads to.

And so, if Firm 1 sets $p_1=10$, Firm 2 will want to set $p_2=15.5$, since a profit of $90.25$ is better than a profit of $80$.

This example is worked out with a specific $p_1$, and this particular $p_1$ makes Firm 2 not undercut Firm 1. The next step is to find out what the highest price that Firm 1 can set without getting Firm 2 to prefer undercutting. This will be $p_1$ in equilibrium, and Firm 2's best response to that $p_1$ will be $p_2$ in equilibrium.