The incident happened on Gilmerton Dykes Avenue, Edinburgh, between 5am and 7am yesterday.
Nobody was injured but damage was caused to the property.
Police said a 24-year-old man has been arrested.
He is due to appear at Edinburgh Sheriff Court tomorrow.
A young mother is understood to have fled her home after it was shot at in the early morning attack.
Gilmerton Dykes Avenue was closed for hours following the incident, in which a gunman fired shots into the back bedroom window of a ground-floor flat.
Armed officers were last night seen pulling over a car in Buckstone Terrace – in a development understood to be connected to the shooting.
It comes less than a year after a string of firearms incidents in the south of the city.
Neighbours reported hearing two “loud booms” and a motorbike speeding away from the scene. No-one was injured in the shooting, which took place at around 6am yesterday.
A young mother and her two children, both under the age of ten, are understood to live at the property.
Police would not confirm whether anyone was home at the time of the incident, but the family was not at the home following the attack and was believed to be in hiding.
Police cordoned off a large section of the street as forensics and CID officers carried out inquiries.
Officers could be seen removing evidence bags from the flat and also carried out a thorough check of the street.
The wider cordon was removed at around 2.15pm, while police tape remained around the targeted home and neighbouring flats until 3pm.
One resident said her young child had heard the motorbike driving away, and said it was concerning for such an incident to happen on their doorstep.
She said the family had only moved to the area a few months ago, adding: “They are new here and it seems they have brought their troubles with them. I hope the kids didn’t see anything.”
Dolls and other children’s toys could be seen scattered on the windowsill of the targeted house.
A neighbour, who asked not to be named, said he and his partner had seen a “green off-road motorbike” drive off after being awoken by a gunshot.
He said: “There were two loud booms. The first time it was a motorbike that drove away and there was another big boom. I thought it was a car crash, or a bin falling over, or something blowing up. They [the family] only moved here a couple of months ago.”
A police spokesman said: “Police are investigating after a firearm was discharged outside a property in Gilmerton Dykes Avenue on Monday between 5am and 7am and resulted in a window being damaged.
“No-one was injured and detectives are now conducting local inquiries to trace those responsible. Anyone with information that can assist police with their investigation asked to come forward immediately.”
Yesterday’s incident follows a spate of incidents in the Gilmerton and Inch areas last year.
The living room window of a family home in Fernieside Avenue, Moredun, was sprayed with bullets on September 9. And shots were fired at a Range Rover in The Murrays Brae and a property in Gilmerton Dykes Drive, while two non-viable bombs were also put outside the house in The Murrays and another home in Walter Scott Avenue on September 20.
Nine men were arrested for the Moredun shooting, however inquiries are ongoing into the last two incidents.