Jay Z has released a new song in response to the police shootings of Alton Sterling and Philando Castile.

The rapper said he wrote the song Spiritual a while ago, but never finished it. He released it on his streaming service Tidal on Friday along with a statement attacking police brutality.

Jay ZJay Z has penned a new song in response to the deaths of Alton Sterling and Philando Castile (Joel Ryan/AP)

He wrote: “Punch (Terrence Henderson, co-president of record label TDE) told me I should drop it when Mike Brown died, sadly I told him, ‘this issue will always be relevant’.”

READ MORE: Beyonce halts Hampden Formation tour show to pay tribute to black police shooting victims

Black teenager Michael Brown was shot dead by a white police officer in Ferguson, Missouri, in August 2014, sparking mass protests and rioting.

Jay Z added: “I’m hurt that I knew his death wouldn’t be the last……

Mike Brown's killing by police in 2014 sparked mass protestsMike Brown’s killing by police in 2014 sparked mass protests (Ted S Warren/AP)

“I’m saddened and disappointed in THIS America – we should be further along. WE ARE NOT.

“I trust God and know everything that happens is for our greatest good, but man…. it’s tough right now.”

He ended by sending his blessings to the families of those that had lost loved ones to “police brutality” and included a quotation by African-American social reformer Frederick Douglass.

Protesters in New York demonstrate against the deaths of Philando Castile and Alton SterlingProtesters in New York on Thursday demonstrate against the deaths of Philando Castile and Alton Sterling (Craig Ruttle/AP)

Alton Sterling was shot in Louisiana on Tuesday after being pinned to the pavement by two white officers. A Minnesota officer shot Philando Castile dead while he was in a car with a woman and a child, just a day later.

A demonstration against their deaths has ended in further tragedy as snipers opened fire on police officers in the heart of Dallas, killing five officers and injuring six others on Thursday evening.

READ MORE: Beyonce halts Hampden Formation tour show to pay tribute to black police shooting victims

Jay Z appears to have written the song at least two years ago, as his statement mentions the death of 18-year-old Brown in 2014.

Jay Z mentions his daughter Blue Ivy, pictured with Beyonce, who held a minute's silence at her concert in GlasgowJay Z mentions his daughter Blue Ivy, pictured here with mother Beyonce, who held a minute’s silence at her concert in Glasgow (Chris Pizzello/AP)

Lyrics include: “I am not poison, no, I am not poison. Just a boy from the hood that got my hands in the air. In despair, don’t shoot, I just wanna do good.”

He references his own daughter Blue Ivy, writing: “Can’t even raise my little daughter, my little Carter. We call her Blue cause it’s sad that, how can I be a dad that, I never had that.”