The firearm was discharged in Woodburn Road, Dalkeith, just after midnight on Sunday morning. No-one was injured in the incident and it’s thought no damage was caused.
Police said extra patrols would be out in force to reassure local residents.
Detectives are looking for a black, older, saloon-type vehicle seen in the area around the time the shot was fired.
Chief Inspector Kenny Simpson, area commander for Midlothian, said: “We’re currently treating this as a targeted incident and I want to thank the local community for their patience as inquiries are conducted.
“I want to reassure residents that there will be an increase in patrols in the area over the coming days and anyone with concerns is welcome to speak to local officers.
“As part of our inquiries we’re urging anyone who may have seen suspicious behaviour in the area around midnight, or has any information about this, to get in touch.
“We’re particularly eager to trace a black older saloon-type vehicle which was travelling in the area around this time and last seen heading in the direction of James Lean Avenue.”