Scottish Coal's application to site an open-cast coal mine at Airfield Farm, near Cousland has been rejected.
It was turned down by Midlothian Council's planning Committee at a meeting on Tuesday.
Campaigners against the planned mine said it was a "fantastic, victorious end to a hard-fought two year campaign".
Scottish Coal said it would be considering the company's options, including the right of appeal.
The company had wanted to extract 10,000 tonnes of coal per week for the next five years to supply coal by lorry to the nearby Cockenzie power station.
It said that if the mine got the go ahead it would create 50 jobs over five years and up to £500,000 for community projects over the lifetime of the site.
Among those objecting to the plans were local people who set up a protest group, Communities Against Airfield Open Cast (CAAOC), which included people from the communities in Cousland and Ormiston. It gatheredmore than 1,060 objections to the proposal.
Its chairman, Dougie McKenzie, said: "It restored our faith in both the planning system and our councillors who have clearly listened to their electorate's concerns."
He said the decision represented the first refusal for an open-cast mine in Scotland in over five years.
East Lothian Council, also raised objections. It said if the plans went ahead, it would have little practical control over noise, vibration, dust and air quality affecting East Lothian.