• The attempt on Thursday morning failed during the third stage of its flight, state media said.
• For North Korean leader Kim Jong Un, a spy satellite is a coveted prize, as it would let him monitor incoming attacks and plot his own more accurately.
North Korea's second attempt to put a spy satellite into space has failed, three months after its first launch crashed into the sea.
The attempt on Thursday morning failed during the third stage of its flight, state media said.
For North Korean leader Kim Jong Un, a spy satellite is a coveted prize, as it would let him monitor incoming attacks and plot his own more accurately.
Pyongyang's space agency has said it will try again in October.
South Korea said it detected the launch of the rocket at around 03:50 local time (18:50 GMT), and that it had flown through international airspace over the Yellow Sea between mainland China and the Korean peninsula.
The launch prompted an emergency warning in Japan's southernmost Okinawa prefecture minutes later, urging residents to take cover indoors. The alert was lifted after about 20 minutes.
Condemning the launch, Japanese Prime Minister Fumio Kishida said: "Behaviour like this goes against the UN resolutions and we're already firmly protesting."
The US urged North Korea to refrain from "further threatening activity" and called on Pyongyang to engage in serious diplomacy.
But although Thursday's failure will have been disappointing for Pyongyang, it appears they've made progress.
A news report in state-run KCNA blamed the failure on "an error in the emergency blasting system during the third-stage flight", and said the problem was "not a big issue".
It seems the rocket carrying the satellite flew further than during the previous attempt. Officials in Pyongyang had described the botched attempt in May as their "gravest failure" while vowing to try again.
And Mr Kim will most likely continue, until he succeeds. Already he is forging ahead with his weapons programme, while refusing all offers to talk to the US.
Thursday's launch comes days after leaders from the US, Japan and South Korea met at a historic summit in Washington. It also follows the start of annual military exercises between Washington and Seoul.